Skip to content

Instantly share code, notes, and snippets.

@askucher
Last active June 20, 2017 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save askucher/736dd3381723dc7fe2119e65f288559e to your computer and use it in GitHub Desktop.
Save askucher/736dd3381723dc7fe2119e65f288559e to your computer and use it in GitHub Desktop.
Example of reactify-ls
require! {
\mobx-react : { observer }
\mobx : { observable }
\react-dom : { render }
\react
}
btn = ({click, text})->
style =
color: \red
padding-left: \5px
a.pug.btn(target='blank' on-click=click style=style) #{text}
input = ({store})->
handle-enter-click = (event) ->
return if event.key-code isnt 13
store.todos.push text: event.target.value
event.target.value = ''
input.pug(on-key-down=handle-enter-click)
Main = observer ({store})->
remove = (todo, _)-->
index = store.todos.index-of todo
return if index < 0
store.todos.splice 1, index
.pug
h3.pug Tasks
for todo in store.todos
.pug
span.pug #{todo.text}
span.pug
btn {text: 'Remove', click: remove todo}
input { store }
window.onload = ->
store = observable do
todos:
* text: 'Do dishes'
...
render do
Main.pug(store=store)
document.body.append-child document.create-element \app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment