This file contains 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'; | |
function unsubscribe(subscribers, callback){ | |
return function(){ | |
var index = subscribers.indexOf(callback); | |
if(index > -1){ | |
subscribers.splice(index, 1); | |
} | |
}; |
This file contains 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
function View(props) { | |
return ( | |
props.allow | |
? HelloWorld({ name: props.name }) | |
: P(null, [Text('Not allowed')]) | |
); | |
} | |
function HelloWorld(props) { | |
return ( |
This file contains 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
function transform(options) { | |
return function(k, v) { | |
return options.hasOwnProperty(k) ? options[k](v, k) : v; | |
}; | |
} |
This file contains 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 Filter = {}; | |
Filter.ELEMENT = 1 | |
Filter.TEXT = 2 | |
Filter.COMMENT = 4; |
This file contains 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 INCREMENT = 'INCREMENT', DECREMENT = 'DECREMENT'; | |
function reducer(state, action) { | |
switch (action.type) { | |
case INCREMENT: | |
return state + 1; | |
case DECREMENT: | |
return state - 1; | |
} | |
} |
This file contains 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
// https://developer.mozilla.org/ru/docs/Web/API/ValidityState | |
var validityState = { valid: false, stepMismatch: true, tooLong: false }; | |
function errorMessage(validity) { | |
// Constant goes in expression | |
switch (true) { | |
// Variable goes in a case clause | |
case !validity.valid: | |
return 'is not a Number'; | |
case validity.stepMismatch: |
This file contains 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
/* global DEBUG */ | |
import Flux from 'flux'; | |
export var Dispatcher = new Flux.Dispatcher(); | |
export function dispatch(type, payload) { | |
if (typeof type !== 'string') { | |
return Promise.reject(new TypeError('Action type should be a string. Received ' + type)); | |
} |