包详细信息

kefir-stopper

Macil7.3kMIT2.2.0

Small Kefir utility for signifying an event has happened

kefir, kefir.js

自述文件

kefirStopper

GitHub license npm version CircleCI Status Greenkeeper badge

This is a small javascript library for use with the Kefir library which creates a Kefir property with a destroy method which causes it to emit an event and end immediately. This works well with Kefir's takeUntilBy method.

Works with Node.js and CommonJS bundlers like Browserify and Webpack.

yarn add kefir-stopper

Usage

Examples use ES6, but ES6 is not necessary to use kefirStopper. (Babel is an excellent tool to use to get ES6!)

const Kefir = require('kefir');
const kefirStopper = require('kefir-stopper');

const stopper = kefirStopper();

function userHitCancel() {
  stopper.destroy();
}

console.log('Loading...');
Kefir.later(5000, null)
  .takeUntilBy(stopper)
  .onValue(() => console.log('Done.'));

A stopper object also has a stopped property which is a boolean that starts as false and is set to true once its destroy method is called.

Types

Both TypeScript and Flow type definitions for this module are included! The type definitions won't require any configuration to use.

更新日志

2.2.0 (2018-09-25)

  • Added TypeScript type definitions.

2.1.1 (2016-11-28)

  • Updated Flow type definitions for Flow 0.36.

2.1.0 (2016-08-29)

  • Added Flow type definitions.

2.0.0 (2015-10-01)

Breaking Changes

  • Require Kefir v3.

1.0.0 (2015-05-11)

Initial release.