Skip to content

Instantly share code, notes, and snippets.

@sslotsky
Created December 3, 2017 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sslotsky/efa32e93960f17ba6293876f98b31609 to your computer and use it in GitHub Desktop.
Save sslotsky/efa32e93960f17ba6293876f98b31609 to your computer and use it in GitHub Desktop.
import { initialize, split } from "apothecary";
import { tunnel, fromProps } from "react-apothecary";
const store = initialize({ n: 1 });
const increment = step => split(n => n + step, "n");
const decrement = step => split(n => n - step, "n");
...
const CounterApp = tunnel(
(state, props) => {
return { n: state.n + props.offset };
},
fromProps(props => ({
inc: increment(props.step),
dec: decrement(props.step)
}))
)(Counter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment