Skip to content

Instantly share code, notes, and snippets.

View savelichalex's full-sized avatar

Alexey Savelev savelichalex

View GitHub Profile
@savelichalex
savelichalex / lazy.js
Created December 26, 2015 10:24 — forked from kana/lazy.js
Lazy evaluation in JavaScript
function delay(expressionAsFunction) {
var result;
var isEvaluated = false;
return function () {
if (!isEvaluated)
result = expressionAsFunction();
return result;
};
}
@savelichalex
savelichalex / Queue.js
Created November 18, 2015 23:00
Universal structure to allow communication between parent and child views
class Queue {
constructor( cb ) {
if( !cb ) {
throw new Error( 'You must specified callback');
}
this._cb = cb;
}
push( data ) {
this._cb( data )
@savelichalex
savelichalex / go.js
Last active October 8, 2015 19:21
channels
var chan = function () {
return [];
};
var toString = Object.prototype.toString;
function go( machine, chan ) {
var gen = machine( chan );
_go( gen, gen.next() );
}