JSPM

pico-stream

0.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q18671F
  • License ISC

A dom render loop using picodom and pull streams

Package Exports

  • pico-stream

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pico-stream) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pico stream

A dom render loop using picodom and pull streams

install

npm install pico-stream

example

$ npm start
var h = require('picodom').h
var S = require('pull-stream')
var render = require('../')

function MyComponent (props) {
    return h('div', {}, [
        'hello ' + props.hello,
        h('br'),
        h('input', { type: 'text', value: props.hello,
            oninput: props.emit.foo })
    ])
}

// pass in view function, event names, and initial state
var app = render(MyComponent, ['foo', 'bar'], { hello: 'world' })

// create a render loop by piping data to app.sink
S(
    app.source.foo(),
    S.map(ev => ({ hello: ev.target.value })),
    S.through(state => console.log('new state', state)),
    app.sink
)

// create new multiplexed stream of all events -- a stream of tuples
// with the event key followed by data:
// [ 'foo', domEvent ]
S(
    app.source(),  
    S.log()
)