Skip to content

Instantly share code, notes, and snippets.

@zalmoxisus
Last active July 28, 2016 16:22
Show Gist options
  • Save zalmoxisus/20efed752d81c1ca9c113d33eb45c1ce to your computer and use it in GitHub Desktop.
Save zalmoxisus/20efed752d81c1ca9c113d33eb45c1ce to your computer and use it in GitHub Desktop.
esnextbin sketch
<!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>
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))
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"jsan": "3.1.2",
"mobx": "2.3.3"
}
}
'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