kefir.combinetemplate

0.1.2 • Public • Published

Kefir.combineTemplate

npm version build status Dependency Status

Generate values based on the Observable and object template. Similar to Bacon.combineTemplate.

Usage

Install

npm install --save kefir.combinetemplate

Basics

import combineTemplate from 'kefir.combinetemplate';
import * as Kefir from 'kefir';
 
let bus1 = Kefir.Bus();
let bus2 = Kefir.Bus();
 
combineTemplate({
  foo : 'bar',
  baz : {
    foo : ['bar', bus1 'qux']
  },
  qux : {
    foo : {
     foo : 'bar'
     baz : bus2
    }
  }
}).subscribe((value)=> {
  console.log(value);
  /* === output ===
  {
    foo : 'bar',
    baz : {
      foo : ['bar', 'BAZ' 'qux']
    },
    qux : {
      foo : {
       foo : 'bar'
       baz : 'QUX'
      }
    }
  }
  */
});
 
bus1.emit('BAZ');
bus2.emit('QUX');

with React

State is updated automatically receives a value from the observables.

componentWillMount() {
  combineTemplate({
    items : store.itemsObservable$,
    count : store.itemsObservable$.map((items) => items.length)
  }).onValue(this.setState.bind(this));
}

Tests

npm test

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i kefir.combinetemplate

Weekly Downloads

4

Version

0.1.2

License

MIT

Last publish

Collaborators

  • ahomu