View throttle-debounce-props-update.js
@stores({ | |
... | |
}) | |
@debouncePropsUpdate({ | |
x: 1000, | |
}) | |
@throttlePropsUpdate({ | |
y: 1000, | |
}) | |
class MyComponent extends React.Component { |
View ComplexClass-0.js
import autobind from './autobind'; | |
class Base { | |
constructor(v) { | |
this.v = v; | |
} | |
} | |
function multiply(by) { | |
return function $multiply(target, name, descriptor) { |
View match-with-example.js
import match, { $, $$$ } from 'match-with'; | |
// l is a list | |
const length = match(l).with( | |
// $() is a single-item named placeholder | |
// $$$() is a rest-collecting named placeholder | |
// .when(predicate) adds a guard predicate | |
clause([$('head'), $$$('tail')]).when(({ tail }) => tail.length > 0)).then(({ head, tail }) => 1 + tail.length), |
View statefulComponent.jsx
const willUnmount = Symbol('unmount'); | |
function statefulComponent(getInitialState, render, componentWillUnmount = () => void 0) { | |
return function*(props) { | |
const internalId = React.pleaseGiveMeAnInternalId(); | |
const state = getInitialState(props); | |
const setState = (nextState) => { | |
Object.assign(state, nextState); | |
React.pleaseRerenderThisInternalId(internalId); | |
}; |
View gist:5cc43425f17701ada3f3
const $x = Symbol(); | |
const t = { $x: 4, y: 5, z: 6 }; | |
const { [$x], ...collect } = t; // collect = { y: 5, z: 6 } |
View super1.js
let x; | |
class A { | |
constructor() { | |
this.a = true; | |
// explictly returns this | |
return this; | |
} | |
} |
View Preferences.sublime-settings
{ | |
"always_show_minimap_viewport": true, | |
"bold_folder_labels": true, | |
"color_scheme": "Packages/Oceanic Next Color Scheme/Oceanic Next.tmTheme", | |
"copy_with_empty_selection": true, | |
"ensure_newline_at_eof_on_save": true, | |
"font_family": "Consolas", | |
"font_options": "subpixel_antialias", | |
"highlight_line": true, | |
"highlight_modified_tabs": true, |
View gist:6d3b7d4d3751c4ea0103
@component(() => ({ | |
users: ['remote://users', {}], | |
})) | |
@component(({ users }) => | |
users.mapKeys((userId) => | |
[`user:${userId}`, [`remote://users/${userId}`, { firstName: 'John', lastName: 'Doe' }]] | |
).toObject() | |
) | |
class UserList extends React.Component { | |
render() { |
View TransformProps.js
const TransformProps = (Component, transform) => class extends React.Component { | |
displayName = Component.displayName; | |
render() { | |
return <Component {...transform(this.props)}>; | |
} | |
}; | |
const transform = (f) => (t) => { | |
r = {}; |
View isExtensionOf.js
// is A an extension of B ? | |
// ex: | |
// class C extends Oject {} | |
// class B extends C {} | |
// class A extends B {} | |
// isExtension(A, B) === true | |
// isExtension(A, C) === true | |
// isExtension(A, Object) === true | |
// isExtension(B, A) === false | |
function isExtensionOf(A, B) { |