Skip to content

Instantly share code, notes, and snippets.

View isaacplmann's full-sized avatar
🎩
✌️

Isaac Mann isaacplmann

🎩
✌️
View GitHub Profile
@isaacplmann
isaacplmann / machine.js
Last active November 5, 2019 20:17
Generated by XState Viz: https://xstate.js.org/viz
const stepMachine = Machine({
id: 'step',
initial: 'step1',
states: {
step1: {},
step2: {}
}
});
const parentMachine = Machine(
const selectionMachine = Machine(
{
id: 'selection',
context: {
selectedIndex: undefined,
},
initial: 'unselected',
states: {
unselected: {
on: {
const selectionMachine = Machine(
{
id: 'selection',
context: {
selectedIndex: undefined,
},
initial: 'unselected',
states: {
unselected: {
on: {
const fetchDataMachine = Machine({
id: 'fetchData',
context: { data: undefined },
initial: 'idle',
states: {
idle: {
on: { FETCH: 'pending'}
},
pending: {
on: {
const fetchMachine = Machine({
id: 'fetch',
initial: 'idle',
states: {
idle: {
on: { FETCH: 'pending'}
},
pending: {
on: {
RESOLVE: 'fulfilled',
@isaacplmann
isaacplmann / machine.js
Last active July 17, 2019 01:39
Generated by XState Viz: https://xstate.js.org/viz
const matchingMachine = Machine(
{
id: 'matching',
context: { choiceOneIndex: undefined, choiceTwoIndex: undefined },
initial: 'answering',
states: {
answering: {
type: 'parallel',
states: {
choiceOne: {
@isaacplmann
isaacplmann / provider-pattern.tsx
Last active September 4, 2018 13:04
A Render Prop by Any Other Name: Angular
@Component({
selector: 'theme-provider',
template: `
<ngx-data-provider key="theme" [data]="{ theme: theme, setTheme: setTheme }">
<ng-content></ng-content>
</ngx-data-provider>`,
})
export class ThemeProvider {
setTheme = theme => this.theme = theme;
theme = 'dark';
@isaacplmann
isaacplmann / provider-pattern.js
Last active August 31, 2018 19:04 — forked from kentcdodds/provider-pattern.js
A Render Prop by Any Other Name: React
const {Provider, Consumer: ThemeConsumer} = React.createContext()
class ThemeProvider extends React.Component {
setTheme = theme => this.setState({theme})
state = {theme: 'dark', setTheme: this.setTheme}
render() {
return <Provider value={this.state} {...this.props} />
}
}
@isaacplmann
isaacplmann / logicViewChart.md
Last active July 25, 2018 15:01
Logic View Chart
Parent Must Control Parent Can Control Child Controls
Logic ? State Reducer ?
View Controlled Component Controllable Component Uncontrolled Component
{
"name": "upgrade-to6",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",