A very easy-to-use asset-loader using promises. Support images, audio and video.
Install using yarn
or npm
:
yarn add loaderz
npm install loaderz --save
You can also try latest features that are not currently live with @next
tag: yarn add loaders@next
import { Loader } from 'loaderz';
const assetLoader = new Loader();
const images = [
'https://picsum.photos/450',
'https://picsum.photos/550',
'https://picsum.photos/650',
];
assetLoader.queue('image', images);
assetLoader.queue('audio', 'http://www.noiseaddicts.com/samples_1w72b820/3721.mp3');
assetLoader.queue('video', 'http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_5mb.mp4');
assetLoader.start().then((response) => console.log('All urls have been loaded, do whatever you want here:', response));
Loader#queue:type, url(string | string[])
: accept 3 different types (audio, image, video).Loader#start
: used to load all queued ressources. Return a promise so you can chain withthen
andcatch
.
All the code is written in Typescript. Feel free to contribute by creating issues and PRs:
- Fork and clone the repo:
git@github.com:username/loaderz.git
- Install all dev-deps:
yarn install
ornpm install
- Run the demo:
yarn demo
(localhost:8080
) - Edit some files.
- Run tests:
yarn test
- Build lib:
yarn build
- Commit and push your edits, then create a PR
Under MIT license, view the license file for more information.