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
import { RESET_THINGS } from "./actions" | |
const enhance = connect(({ things }) => ({ things }), { | |
resetThings: things => ({ | |
type: RESET_THINGS, | |
things | |
}) | |
}) | |
const CoolComponent = ({ things, resetThings }) => ( | |
<Fragment> |
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
// To connect to a component | |
const enhance = connect(["things", "things.reset"]) | |
const CoolComponent = ({ things }) => ( | |
<Fragment> | |
<button onClick={things.reset}> Reset </button> | |
{things.i.map(i => <span>{i}</span>)} | |
</Fragment> | |
) | |
enhance(CoolComponent) |
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
// define action types... IDK why peeps do this | |
export const REPLACE_THINGS = "REPLACE_THINGS" | |
export const REMOVE_THING = "REMOVE_THING" | |
export const ADD_THING = "ADD_THING" | |
export const RESET_THINGS = "RESET_THINGS" | |
export const CLICKED_A_THING = "CLICKED_A_THING" | |
export const UI_THING_ON = "UI_THING_ON" | |
export const UI_THING_OFF = "UI_THING_OFF" |
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
// from http://forwardjs.com/university/a-million-ways-to-fold-in-js | |
'use strict' | |
const first = xs => xs[0] | |
const rest = xs => xs.slice(1) | |
const concat = (xs1, xs2) => [ ...xs1, ...xs2 ] | |
// recursion | |
const sum = xs => xs.length === 0 ? |