Skip to content

Instantly share code, notes, and snippets.

@lmatteis
Last active February 2, 2017 22:15
Show Gist options
  • Save lmatteis/b1d18f863f589c496dc604b95ca56454 to your computer and use it in GitHub Desktop.
Save lmatteis/b1d18f863f589c496dc604b95ca56454 to your computer and use it in GitHub Desktop.
assertSourcesSinks example
function main(sources) {
const sinks = {
DOM: sources.DOM.select('.field').events('input')
.map(ev => ev.target.value)
.startWith('')
.map(name =>
div([
label('Name:'),
input('.field', {attrs: {type: 'text'}}),
hr(),
h1('Hello ' + name),
])
)
};
return sinks;
}
const domSource = {
'select:events': () => ({
a: { target: { value: 'foo' } },
b: { target: { value: 'bar' } }
})
};
const domSink = {
x: div([
label('Name:'),
input('.field', {attrs: {type: 'text'}}),
hr(),
h1('Hello foo'),
]),
y: div([
label('Name:'),
input('.field', {attrs: {type: 'text'}}),
hr(),
h1('Hello bar'),
])
}
assertSourcesSinks({
DOM: { 'ab|': domSource },
}, {
DOM: { 'xy|': domSink }
}, main, done);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment