Last active
February 2, 2017 22:15
-
-
Save lmatteis/b1d18f863f589c496dc604b95ca56454 to your computer and use it in GitHub Desktop.
assertSourcesSinks example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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