For reference, here is a standard synchronous Redux action creator:
export const simpleAction = () => {
return {
type: actionTypes.PERFORM_SIMPLE_ACTION
};
}
(function(){ | |
function addWindowEvent (event, fn) { | |
var old = window[event]; | |
if (typeof old !== 'function') { | |
window[event] = fn; | |
return; | |
} | |
window[event] = function () { | |
old.apply(window, arguments); |
// Native selectors. | |
(function(window, document) { | |
'use strict'; | |
var noop = function() { | |
}; | |
// DOCUMENT LOAD EVENTS | |
// not needed at the bottom of the page | |
document.addEventListener('DOMContentLoaded', noop); |
Good tester: http://www.regexr.com/ | |
Cheat sheet: http://ole.michelsen.dk/tools/regex.html | |
| = or | |
(ab|ba) | |
() = capture | |
(Java|Ecma)Script | |
(?:Java|Ecma)Script => don't care about capture | |
// negated character classes |
(function() { | |
var person = { | |
sayName: function() { | |
console.log('my name is ' + this.name); | |
} | |
}; | |
var bob = Object.create(person); | |
bob.name = 'bob'; |
let _callbacks = {}; | |
const events = { | |
on(name, cb) { | |
_callbacks[name] = _callbacks[name] || []; | |
_callbacks[name].push(cb); | |
}, | |
dispatch(name, data) { | |
setTimeout(function() { | |
(_callbacks[name] || []).forEach(cb => cb(data)); | |
}); |
const data = { | |
'key': 'mixed-characters', | |
'summary': 'Привет!' | |
}; |
// @flow | |
import fs from 'fs'; | |
import { Observable } from 'rxjs'; | |
type Options = { | |
highWaterMark: number, | |
encoding: string, | |
} | |
const defaultOptions: Options = { |
import React, { Component } from 'react'; | |
class Student extends Component<{ student: Person }> { | |
render() { | |
// Renders out a draggable student | |
} | |
} | |
class InnerList extends Component<{ students: Person[] }> { | |
// do not re-render if the students list has not changed |
const getIdMap = memoizeOne((array) => { | |
return array.reduce((previous, current) => { | |
previous[current.id] = array[current]; | |
return previous; | |
}, {}); | |
}); | |
const foo = { id: 'foo' }; | |
const bar = { id: 'bar' }; |