0.0.7 • Published 10 years ago

observe-stream v0.0.7

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

observe-stream

observe-stream is a thin layer on top of stream-mixin that turns Objects and Functions into duplex streams so they can accept and announce changes to their properties. Its intended use is multi-way data-binding in the browser.

Browser support

Install

$ npm install observe-stream

Usage

Hate reading code? See this example running!

var stream = require('stream-mixin')
var observe = require('observe-stream')

var model = {
  name: 'Alice'
}

// Mixin pre-configured duplex stream.
observe.call(model)

var input = document.createElement('input')

// Make duplex stream from scratch.
stream.call(input)
input.readable = true
input.writable = true
input.write = function(data) {
  this.value = data.name
}
input.end = function() {}

input.value = model.name
input.addEventListener('input', function() {
  this.emit('data', { name: this.value })
})

// Make them talk
model.pipe(input).pipe(model)

// Let us interact
window.model = model
window.input = input
document.body.appendChild(input)

License

MIT

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago

0.0.0

11 years ago