0.0.1 • Published 8 years ago

pull-observ-struct v0.0.1

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

pull observ struct

An isntance of observ-struct that listens to a pull stream. Instead of calling .set on an observable, connect it to a source stream.

install

$ npm install pull-observ-struct

example

var State = require('pull-observ-struct')
var S = require('pull-stream')

// normal observ interface
var state = State({})

// subscribe to changes
// but with an `end` listener too
var stopListening = state(function onChange (data) {
    console.log('change', data)
}, function onEnd (err) {
    console.log('end')
})

// there is no `.set` method
// all changes must come from the stream
S(
    S.values([{ test: 'test' }]),
    state.sink
)

// get state
var s = state()

// remove change and end listeners
stopListening()