Created
June 23, 2017 10:11
-
-
Save askucher/8173dc8815dce0df547ef7f3b5c5796e to your computer and use it in GitHub Desktop.
This file contains 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
// Generated by LiveScript 1.5.0 | |
(function(){ | |
var observer, observable, render, react, btn, input, Main; | |
observer = require('mobx-react').observer; | |
observable = require('mobx').observable; | |
render = require('react-dom').render; | |
react = require('react'); | |
btn = function(arg$){ | |
var click, text; | |
click = arg$.click, text = arg$.text; | |
return react.createElement('a', { | |
target: 'blank', | |
onClick: click, | |
className: 'btn' | |
}, text); | |
}; | |
input = function(arg$){ | |
var store, handleEnterClick; | |
store = arg$.store; | |
handleEnterClick = function(event){ | |
if (event.keyCode !== 13) { | |
return; | |
} | |
store.todos.push({ | |
text: event.target.value | |
}); | |
return event.target.value = ''; | |
}; | |
return react.createElement('input', { | |
onKeyDown: handleEnterClick, | |
className: 'input' | |
}); | |
}; | |
Main = observer(function(arg$){ | |
var store, remove, children, todo; | |
store = arg$.store; | |
remove = curry$(function(todo, _){ | |
var index; | |
index = store.todos.indexOf(todo); | |
if (index < 0) { | |
return; | |
} | |
return store.todos.splice(1, index); | |
}); | |
return react.createElement('div', { | |
className: 'root root1662774725' | |
}, children = [ | |
react.createElement('h3', {}, 'Tasks'), (function(){ | |
var i$, ref$, len$, results$ = []; | |
for (i$ = 0, len$ = (ref$ = store.todos).length; i$ < len$; ++i$) { | |
todo = ref$[i$]; | |
results$.push(react.createElement('div', {}, children = [ | |
react.createElement('span', {}, todo.text), react.createElement('span', {}, children = btn({ | |
text: 'Remove', | |
click: remove(todo) | |
})) | |
])); | |
} | |
return results$; | |
}()), input({ | |
store: store | |
}), react.createElement('hr', {}) | |
]); | |
}); | |
window.onload = function(){ | |
var store; | |
store = observable({ | |
todos: [{ | |
text: 'Do dishes' | |
}] | |
}); | |
return render(react.createElement(Main, { | |
store: store | |
}), document.body.appendChild(document.createElement('app'))); | |
}; | |
function curry$(f, bound){ | |
var context, | |
_curry = function(args) { | |
return f.length > 1 ? function(){ | |
var params = args ? args.concat() : []; | |
context = bound ? context || this : this; | |
return params.push.apply(params, arguments) < | |
f.length && arguments.length ? | |
_curry.call(context, params) : f.apply(context, params); | |
} : f; | |
}; | |
return _curry(); | |
} | |
}).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment