How to use the atom.Disposable function in atom

To help you get started, we’ve selected a few atom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github viddo / atom-textual-velocity / lib / Disposables.js View on Github external
add(...values) {
    // until https://github.com/eslint/eslint/issues/12117 is resolved:
    // eslint-disable-next-line no-unused-vars
    for (let val of values) {
      if (!Disposable.isDisposable(val)) {
        if (typeof val === "function") {
          val = new Disposable(val);
        } else {
          console.error(
            `val is of type ${typeof val}, was expected to be disposable or a function`
          );
        }
      }
      super.add(val);
    }
  }
}
github viddo / atom-textual-velocity / src / notational-panel.js View on Github external
_makeDisposable(o) {
    if (Disposable.isDisposable(o)) return o;
    if (typeof o === 'function') {
      return new Disposable(o);
    } else {
      throw new Error('must be a function');
    }
  }
github t9md / atom-narrow / lib / main.js View on Github external
atom.workspace.observeTextEditors(editor => {
        let sub
        editor.element.addEventListener('mousedown', onMouseDown, true)
        const removeListener = () => editor.element.removeEventListener('mousedown', onMouseDown, true)
        this.subscriptions.add((sub = new Disposable(removeListener)))
        editor.onDidDestroy(() => this.subscriptions.remove(sub))
      })
    )
github file-icons / atom / lib / ui.js View on Github external
subscribe(eventName, handler){
		return this.emitter
			? this.emitter.on(eventName, handler)
			: new Disposable(() => {});
	}

atom

shared, synchronous, independent state for javascript apps

ISC
Latest version published 1 year ago

Package Health Score

46 / 100
Full package analysis