- expression-oriented programming one of the great advances of FP
- expressions plug together like legos, making more malleable programming experience in-the-small
Write in an expression-oriented style, scoping variables as locally as possible:
| // | |
| // Author: Jonathan Blow | |
| // Version: 1 | |
| // Date: 31 August, 2018 | |
| // | |
| // This code is released under the MIT license, which you can find at | |
| // | |
| // https://opensource.org/licenses/MIT | |
| // | |
| // |
React Fiber is an ongoing reimplementation of React's core algorithm. It is the culmination of over two years of research by the React team.
| import React, { PropTypes } from 'react'; | |
| import classNames from 'classnames'; | |
| import { autobind } from 'core-decorators' | |
| import PureComponent from './pure'; | |
| @withStyles(style) | |
| export default class Input extends PureComponent { | |
| static propTypes = { | |
| onChange: PropTypes.func.isRequired, |
| /** | |
| * Currying Functions with Named Parameters. | |
| * @gunar, @drboolean, @dtipson 2016 | |
| * | |
| * Why does it return a thunk, though? | |
| * Because in JS named arguments are opaque. There is no way of getting a function's named arguments list. | |
| * e.g. | |
| * const foo = function ({ a, b }) { } | |
| * console.log(foo.arguments) // Throws. Ideally would return ['a', 'b']. | |
| * |
| class TodoStore extends BaseStore { | |
| // Constructor is executed in the config phase. | |
| constructor(stores, initialState) { | |
| super(stores, initialState) // ensures initial state loads for SSR | |
| // Other store initialization... | |
| } | |
| // This is executed in the run phase, after all stores have initialized. | |
| storeDidInitialize(stores) { |
| // ------------ | |
| // counterStore.js | |
| // ------------ | |
| import { | |
| INCREMENT_COUNTER, | |
| DECREMENT_COUNTER | |
| } from '../constants/ActionTypes'; | |
| const initialState = { counter: 0 }; |
key is pretty much crucial for state perservation in React. As of React 0.13 it can't do the following things:
<Comp key={1} /><Comp key={1} />You know what method is being and you want to figure out how it got there. Raising an exception is a bit harsh since all you want is a stack trace
puts caller
Seriously. It's that easy. If you're getting too much information you could
| <script src="https://apis.google.com/js/plusone.js"> | |
| </script> | |
| <div class="g-comments" | |
| data-href="[URL]" | |
| data-width="642" | |
| data-first_party_property="BLOGGER" | |
| data-view_type="FILTERED_POSTMOD"> | |
| </div> |