Skip to content

Instantly share code, notes, and snippets.

View alexeyraspopov's full-sized avatar
✍️
Working on something exciting

Oleksii alexeyraspopov

✍️
Working on something exciting
View GitHub Profile
@alexeyraspopov
alexeyraspopov / links.md
Created December 6, 2014 18:15
Полный список ссылок к докладу о функциональном программировании на WSD 2014
'use strict';
function unsubscribe(subscribers, callback){
return function(){
var index = subscribers.indexOf(callback);
if(index > -1){
subscribers.splice(index, 1);
}
};
function View(props) {
return (
props.allow
? HelloWorld({ name: props.name })
: P(null, [Text('Not allowed')])
);
}
function HelloWorld(props) {
return (
function transform(options) {
return function(k, v) {
return options.hasOwnProperty(k) ? options[k](v, k) : v;
};
}
var Filter = {};
Filter.ELEMENT = 1
Filter.TEXT = 2
Filter.COMMENT = 4;
const INCREMENT = 'INCREMENT', DECREMENT = 'DECREMENT';
function reducer(state, action) {
switch (action.type) {
case INCREMENT:
return state + 1;
case DECREMENT:
return state - 1;
}
}
// 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:
@alexeyraspopov
alexeyraspopov / README.md
Last active September 22, 2015 15:16
Transmit nextProps issue

Steps to reproduce

  1. Clone this gist git clone git@gist.github.com:7ac0d01dc7fdbecaab69.git && cd 7ac0d01dc7fdbecaab69
  2. Install dependencies npm install
  3. Start project npm start
  4. Open http://localhost:8000 in your browser
  5. Click on any item in projects list

Expected: models list will have one item

/* 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));
}

Work in isolation

┌─ Route ──────────────────┐
│                          │
│ ┌─ Container ──────────┐ │
│ │                      │ │
│ │ ┌─ List ───────────┐ │ │
│ │ │                  │ │ │
│ │ │ ┌─ Item ───────┐ │ │ │