parsegraph-method
TypeScript icon, indicating that this package has built-in type declarations

1.4.26 • Public • Published

Method

This contains a single class that represents a method, whose this-argument is saved at construction-time.

import Method from 'parsegraph-method';

const method = new Method();

class Object {
    _onUpdate: Method;

    constructor() {
        this._onUpdate = new Method();
    }

    onUpdate(listener: ()=>void, listenerObj?: object) {
        // Listener this-object is optional.
        this._onUpdate.set(listener, listenerObj);
    }

    update() {
        // Safe to call even if unset.
        this._onUpdate.call();
    }
}

Readme

Keywords

none

Package Sidebar

Install

npm i parsegraph-method

Weekly Downloads

21

Version

1.4.26

License

MIT

Unpacked Size

8.87 kB

Total Files

10

Last publish

Collaborators

  • dafrito
  • tracy3