Skip to content

micro-js/observable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

observable

Build status Git tag NPM version Code style

Minimal observable. DOES NOT ADHERE TO ES7 OBSERVABLE SPEC.

Installation

$ npm install @f/observable

Usage

var observable = require('@f/observable')

var o = observable()
o.subscribe(function (next) {
  console.log(next)
}) // => 1 , 2
o(1)
o(2)

API

observable()

Returns: observable

obs.subscribe(listener)

  • listener - add listener with signature listener(nextVal)

Returns: unsubscribe function

(val) - obs(val)

  • val - next value to send to listeners

() - obs()

Returns: Current value of the observable

License

MIT