observable.js 488 B

123456789101112131415
  1. // Copyright 2017-2020 @polkadot/react-api authors & contributors
  2. // This software may be modified and distributed under the terms
  3. // of the Apache-2.0 license. See the LICENSE file for details.
  4. const createObservable = require('@polkadot/api-rx/observable');
  5. module.exports = function observable (method) {
  6. const fn = () => Promise.resolve(12345);
  7. fn.unsubscribe = () => Promise.resolve(true);
  8. return createObservable(`section_${method}`, method, {
  9. [method]: fn
  10. })();
  11. };