Skip to content

Instantly share code, notes, and snippets.

@arvitaly
arvitaly / composition.js
Created September 20, 2016 09:57
Example of change state in js-modules
var state = require('./state');
var f1 = require('./f1');
var f2 = require('./f2');
try{
f1();//Change state, really bad
var newState = f2();// pure function
//await f3
//yield* f4
}catch(e){
@arvitaly
arvitaly / gist:8ae581f94650d5a9369f91421641cdfa
Created September 9, 2016 18:57
Расширение прототипа cellx
var cellx = require('cellx');
var x = new cellx.Cell
cellx.Cell.prototype.if = function (trueCondition) {
this.subscribe(function () {
this.get() && trueCondition()
});
this.get() && trueCondition()
}
@arvitaly
arvitaly / js
Created September 7, 2016 19:20
Не происходит асинхронная подписка на ячейку cellx?
var cellx = require('cellx');
var a = cellx(55);
var x = cellx((push) => {
//a() //Если раскомментировать эту строку, то x начинает пересчитываться!
setTimeout(() => {
push("test" + a());
}, 100)
})
x('addChangeListener', () => {
console.log("addChangeListener, x:: ", x());
@arvitaly
arvitaly / gist:0814c1ac9dc28d4ff717524fd48ef65e
Created September 7, 2016 19:20
Не происходит асинхронная подписка на ячейку cellx?
var cellx = require('cellx');
var a = cellx(55);
var x = cellx((push) => {
//a() //Если раскомментировать эту строку, то x начинает пересчитываться!
setTimeout(() => {
push("test" + a());
}, 100)
})
x('addChangeListener', () => {
console.log("addChangeListener, x:: ", x());