{"id":21604236,"url":"https://github.com/vogelino/cycle-image-loading-driver","last_synced_at":"2025-03-18T14:07:34.390Z","repository":{"id":42790993,"uuid":"273248756","full_name":"vogelino/cycle-image-loading-driver","owner":"vogelino","description":"A cycle.js driver for preloading images","archived":false,"fork":false,"pushed_at":"2023-01-06T09:18:16.000Z","size":963,"stargazers_count":0,"open_issues_count":7,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-25T09:42:46.768Z","etag":null,"topics":["cyclejs","drivers","image-loading","preloading","preloading-images","reactive-programming","rxjs","streams"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vogelino.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-18T13:40:29.000Z","updated_at":"2020-09-10T05:52:04.000Z","dependencies_parsed_at":"2023-02-05T18:46:11.910Z","dependency_job_id":null,"html_url":"https://github.com/vogelino/cycle-image-loading-driver","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vogelino%2Fcycle-image-loading-driver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vogelino%2Fcycle-image-loading-driver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vogelino%2Fcycle-image-loading-driver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vogelino%2Fcycle-image-loading-driver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vogelino","download_url":"https://codeload.github.com/vogelino/cycle-image-loading-driver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244236060,"owners_count":20420753,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cyclejs","drivers","image-loading","preloading","preloading-images","reactive-programming","rxjs","streams"],"created_at":"2024-11-24T19:18:53.237Z","updated_at":"2025-03-18T14:07:34.371Z","avatar_url":"https://github.com/vogelino.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://img.shields.io/npm/v/cycle-image-loading-driver.svg?style=flat)](https://npmjs.org/package/cycle-image-loading-driver 'View this project on npm')\n\n# [Cycle.js driver](https://cycle.js.org/drivers.html) for preloading images\n\nThis driver takes in a sink stream of images to load and returns a source stream that emits whenever an image is loaded.\n\n## Install\n\n### NPM\n\n```sh\nnpm install --save cycle-image-loading-driver\n```\n\n### Yarn\n\n```sh\nyarn add cycle-image-loading-driver\n```\n\n## Creating the driver\n\nLike any other driver, the (default) function `makeImageLoadingDriver` should be called in the run function.\n\n```js\nrun(main, {\n\timagesToLoad: makeImageLoadingDriver(),\n})\n```\n\nThe function `makeImageLoadingDriver` takes no options.\n\n## Sink\n\nThe sink `imagesToLoad` should be a stream emiting an array of image urls.\n\n```js\nfunction main() {\n\t// ...\n\treturn {\n\t\timagesToLoad: xs.of([url1, url2, url3]),\n\t}\n}\n```\n\n## Source\n\nThe source stream produced emits an object in which the keys is the image URL and the value an object with properties `loaded` and possibly `error`.\n\n```js\nfunction main(sources) {\n\tsources.imagesToLoad.map((images) =\u003e {\n\t\tconst isImg1Loaded = images[img1Url].loaded\n\t\t//...\n\t})\n\t//...\n}\n```\n\nTo loop through all images use `Object.keys`\n\n```js\nfunction main(sources) {\n\tsources.imagesToLoad.map((images) =\u003e {\n\t\tconst allImages = Object.keys(images).map((key) =\u003e {\n\t\t\tconst imgObj = images[key]\n\t\t\treturn { ...imgObj, id: key }\n\t\t})\n\t\t//...\n\t})\n\t//...\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvogelino%2Fcycle-image-loading-driver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvogelino%2Fcycle-image-loading-driver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvogelino%2Fcycle-image-loading-driver/lists"}