@enea-entertainment/runner
v2.0.0
Published
Alternative to events / signals.
Downloads
6
Maintainers
Readme
Runner
Alternative to events / signals.
Installation
npm install --save-dev @enea-entertainment/runner
Usage example
import { Runner } from '@enea-entertainment/runner';
// Runner has no arguments
// each object subscribed to this Runner will have its update method called on dispatch
this.updateRunner = new Runner('update');
// subscribe someObject1 to updateRunner
this.updateRunner.add(someObject1);
// dispatching updateRunner will call someObject1.update() method
this.updateRunner.dispatch();
// cleanup
this.updateRunner.destroy();
// ---------------------------------------------------------------------
// Runner has 2 arguments, notice number 2 after |
this.positionRunner = new Runner('setPosition|2');
// subscribe someObject2 to positionRunner
this.positionRunner.add(someObject2);
// dispatching positionRunner will call someObject2.setPosition() method with 2 arguments (x, y)
this.positionRunner.dispatch(x, y);
// cleanup
this.positionRunner.destroy();
Thank you
- Runner is based on mini-runner by GoodBoyDigital
License
MIT, see LICENSE for details.