task-loader
Class for loading assets
Installation
yarn add task-loader
npm i -S task-loader
Usage
Task loader usage
; // Create the task loader instance; // Add events to the tasktaskLoader.addEventListenerTaskLoaderEvent.START,console.log'Start';taskLoader.addEventListenerTaskLoaderEvent.UPDATE,console.log'Update', data.progress;taskLoader.addEventListenerTaskLoaderEvent.COMPLETE,console.log'Complete';taskLoader.addEventListenerTaskLoaderEvent.FAILURE,console.log'Failure during loading'; // Load the taskstaskLoader.loadTasks.then;.catch;
Individual task usage
; // Create the task; // Add events to the tasktask.addEventListenerTaskLoaderEvent.START,console.log'Start';task.addEventListenerTaskLoaderEvent.UPDATE,console.log'Update', data.progress;task.addEventListenerTaskLoaderEvent.COMPLETE,console.log'Complete';task.addEventListenerTaskLoaderEvent.FAILURE,console.log'Failure during loading'; task.load.then;.catch;
cacheManager usage
; // Manually add an asset to the cacheManager;cacheManager.add'image', asset, 'bar'; // Retrieve an asset from the cache manager once it's loaded; // Retrieve images stored in a namespace; // Remove assets from cachecacheManager.remove'path/to/video.mp4'; // Remove assets within a namespacecacheManager.remove'foo';
Note
Keep in mind when tree shaking a module it will include all other dependencies for all tasks in your project (this means including Howler). If you do not want this, please include theme separately:
;; ;;;;;
Example
I've included an example setup where you can see the loader in action, to run the project follow these steps:
git clone https://github.com/larsvanbraam/task-loader.git
cd task-loader/example
yarn
yarn dev
- Open your browser
localhost:8080
or click this link to preview online
Documentation
View the generated documentation.
Building
In order to build task-loader, ensure that you have Git and Node.js installed.
Clone a copy of the repo:
git clone https://github.com/larsvanbraam/task-loader.git
Change to the task-loader directory:
cd task-loader
Install dev dependencies:
yarn
Use one of the following main scripts:
yarn build # build this project yarn dev # run compilers in watch mode, both for babel and typescript yarn test # run the unit tests incl coverage yarn test:dev # run the unit tests in watch mode yarn lint # run eslint and tslint on this project yarn doc # generate typedoc documentation
When installing this module, it adds a pre-commit hook, that runs lint and prettier commands before committing, so you can be sure that everything checks out.
Contribute
View CONTRIBUTING.md
Changelog
View CHANGELOG.md
Authors
View AUTHORS.md
LICENSE
MIT © Lars van Braam