Skip to content

Instantly share code, notes, and snippets.

@ramnathv
Created April 28, 2016 17:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ramnathv/728b8979a876a2660cd2d8c1cb3fca49 to your computer and use it in GitHub Desktop.
Save ramnathv/728b8979a876a2660cd2d8c1cb3fca49 to your computer and use it in GitHub Desktop.
Mithril + Mobx Hello World
<div class="container" id="main">
<div class="row">
<div class="col-xs-12 col-md-6">
<div id="app"></div>
</div>
</div>
</div>
/** @jsx m */
const store = mobx.observable({
userName: "Ramnath"
})
const Hello = {
view(ctrl, props){
return (
<h2>Hello {props.store.userName}</h2>
)
}
}
mobx.autorun(() =>
m.mount(
document.getElementById("app"),
<Hello store={store} />
)
)
<script src="//npmcdn.com/mobx@2.1.0/lib/mobx.umd.js"></script>
<script src="//npmcdn.com/mithril@0.2.4/mithril.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment