2.0.0 • Published 6 months ago

@enea-entertainment/runner v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Runner

Alternative to events / signals.


Installation

npm install --save-dev @enea-entertainment/runner

NPM


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


License

MIT, see LICENSE for details.