Cycle.js driver for preloading images
This driver takes in a sink stream of images to load and returns a source stream that emits whenever an image is loaded.
Install
NPM
npm install --save cycle-image-loading-driver
Yarn
yarn add cycle-image-loading-driver
Creating the driver
Like any other driver, the (default) function makeImageLoadingDriver
should be called in the run function.
The function makeImageLoadingDriver
takes no options.
Sink
The sink imagesToLoad
should be a stream emiting an array of image urls.
{ // ... return imagesToLoad: xs }
Source
The 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
.
{ sourcesimagesToLoad //...}
To loop through all images use Object.keys
{ sourcesimagesToLoad //...}