@enea-entertainment/runner
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

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.

/@enea-entertainment/runner/

    Package Sidebar

    Install

    npm i @enea-entertainment/runner

    Homepage

    www.enea.sk/

    Weekly Downloads

    3

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    16.8 kB

    Total Files

    6

    Last publish

    Collaborators

    • enea-entertainment