made with esnextbin
Last active
July 28, 2016 16:22
-
-
Save zalmoxisus/20efed752d81c1ca9c113d33eb45c1ce to your computer and use it in GitHub Desktop.
esnextbin sketch
This file contains hidden or 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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>ESNextbin Sketch</title> | |
<!-- put additional styles and scripts here --> | |
</head> | |
<body> | |
<!-- put markup and other contents here --> | |
</body> | |
</html> |
This file contains hidden or 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
import jsan from 'jsan'; | |
import mobx from 'mobx'; | |
var todoFactory = function (title, store) { | |
return mobx.observable({ | |
store: store, // <-- remove this line to get it work | |
title: title | |
} | |
); | |
}; | |
var todoListFactory = function () { | |
return mobx.observable({ | |
todos: [], | |
addTodo: mobx.action(function addTodo (todo) { | |
this.todos.push(todo); | |
}) | |
}); | |
}; | |
var store = todoListFactory(); | |
store.addTodo(todoFactory('Write simpler code', store)); | |
console.log(jsan.stringify(store, null, null, false)) |
This file contains hidden or 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
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0", | |
"dependencies": { | |
"jsan": "3.1.2", | |
"mobx": "2.3.3" | |
} | |
} |
This file contains hidden or 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
'use strict'; | |
var _jsan = require('jsan'); | |
var _jsan2 = _interopRequireDefault(_jsan); | |
var _mobx = require('mobx'); | |
var _mobx2 = _interopRequireDefault(_mobx); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
var todoFactory = function todoFactory(title, store) { | |
return _mobx2.default.observable({ | |
store: store, // <-- remove this line to get it work | |
title: title | |
}); | |
}; | |
var todoListFactory = function todoListFactory() { | |
return _mobx2.default.observable({ | |
todos: [], | |
addTodo: _mobx2.default.action(function addTodo(todo) { | |
this.todos.push(todo); | |
}) | |
}); | |
}; | |
var store = todoListFactory(); | |
store.addTodo(todoFactory('Write simpler code', store)); | |
console.log(_jsan2.default.stringify(store, null, null, false)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment