1.1.4 • Published 5 years ago

notifiers v1.1.4

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

code style: prettier

Include in your project

npm install notifiers

See https://www.npmjs.com/package/notifiers

Local Build

Dependencies

Local setup

  • Run npm install
  • Run npm build:dev for development builds
  • Run npm build:prod for publish builds

Example

import Notifier from 'notifiers';

function myNotifyingFunction() {
  return new Notifier((success, failure) => {
    let count = 1;
    const interval = setInterval(() => {
      success(count++);
    }, 1000);

    return () => {
      // cleanup to call when `clear`
      // is called on the notifier
      clearInterval(interval);
    };
  });
}

myNotifyingFunction()
  .onSuccess((value, notifier) => {
    // do stuff with value
  })
  .onFail((error, notifier) => {
    // handle error
  });

Cancelling notifiers

  const notifier = new Notifier(/*...*/);

  notifier.clear();

Got lots of notifiers?

  const notifiers = [/* array of notifiers here */];

  Notifier.any(notifiers)
    .onSuccess((valueFromAnyNotifier, notifier) => {
      /* use the value */
    })
    .onFailure((error, notifier) => {
      /* handle the error */
    });