Reactor.js Experiments
by ramnathv
HTML
<script src="//cdn.rawgit.com/fynyky/reactor.js/master/reactor.js"></script>
<h1 id='fullName' class='output'>Hello</h1>
<input type='text' id='firstName' class='input'>
<input type='text' id='lastName' class='input'>
CoffeeScript
input = {}
foo = (id) ->
el = document.getElementById(id)
input[id] = Signal("")
el.addEventListener "input", (e) ->
input[id](e.target.value)
foo('firstName')
foo('lastName')
output = {}
output['fullName'] = Signal ->
input.firstName() + " " + input.lastName()
Observer ->
console.log
el = document.getElementById('fullName')
el.innerHTML = if output.fullName() is " " then 'Hello' else output.fullName()
#Observer -> console.log output.fullName()