Skip to content

Instantly share code, notes, and snippets.

@avanslaars
Created April 16, 2016 13:30
Show Gist options
  • Save avanslaars/e72e49deaeede6cbcad86b4dc2c26eaa to your computer and use it in GitHub Desktop.
Save avanslaars/e72e49deaeede6cbcad86b4dc2c26eaa to your computer and use it in GitHub Desktop.
Boilerplate code for Motorcycle on Webpackbin.com - This is a direct port of the CycleJS boilerplate to Motorcycle
//http://www.webpackbin.com/VkPA2Qj1Z
import Motorcycle from '@motorcycle/core';
import {div, label, input, hr, h1, makeDOMDriver} from '@motorcycle/dom';
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', {attributes: {type: 'text'}}),
hr(),
h1('Hello ' + name)
])
)
};
return sinks;
}
Motorcycle.run(main, { DOM: makeDOMDriver('#app') });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment