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
| var state = mobx.observable({ | |
| todos : [], | |
| visibilityFilter : "ALL", | |
| addTodoItem : action(function (text, completed) { | |
| this.todos.push({text, completed}) | |
| }), | |
| setVisibilityFilter : action(function (filter) { | |
| this.visibilityFilter = filter; |
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
| // calling this version of bind inside .render() should only create each bound function once | |
| // WARNING: I didn't even ran this code :P so I'm not sure if it works | |
| const _cache = new WeakMap(); | |
| const _cmpArray = (arr1, arr2) => (arr1.length === arr2.length) && | |
| (arr1.every((v,i)=> (v === arr2[i]))); | |
| function bind(fn, context, ...args) { |
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
| const _ = require("lodash"); | |
| const Navigo = require("navigo"); | |
| class Router { | |
| constructor(routes, config) { | |
| let handler = config.handler || (() => null); | |
| let before = config.before || ((d) => d()); | |
| let router = new Navigo(null, true); | |
| _(routes).each( |
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
| // returns the value in a nested associative structure, | |
| // just like (get-in) in clojure | |
| var getIn = function (obj, path) { | |
| if (!_(path).isArray()) // normalize | |
| path = _(arguments).toArray().rest().value(); | |
| if (path.length === 0) | |
| return obj; | |
| if (!_(obj).has(_.first(path))) |
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
| class SimpleAssetManager { | |
| // loader is the function that will actually do the fetching & return a promise... | |
| constructor(loader, options = {}) { | |
| this._cache = {}; | |
| this._cacheLimit = (options.cacheLimit || 1000); | |
| this._cacheTTL = (options.cacheTTL || 10*1000); // ms | |
| this._taskLimit = (options.tasks || 4); | |
| this._loader = loader; |
NewerOlder