npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

observe-stream

0.0.7 • Public • Published

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

install

npm i observe-stream

Downloadsweekly downloads

33

version

0.0.7

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability