Skip to content

Instantly share code, notes, and snippets.

View cellog's full-sized avatar

Gregory Beaver cellog

View GitHub Profile
@cellog
cellog / machine.js
Last active November 11, 2019 16:36
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@cellog
cellog / machine.js
Created November 11, 2019 16:10
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@cellog
cellog / machine.js
Last active November 14, 2019 16:51
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@cellog
cellog / machine.js
Last active November 10, 2019 20:54
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@cellog
cellog / machine.js
Last active November 9, 2019 00:50
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@cellog
cellog / App.js
Last active October 8, 2019 02:45
Math flashcards
import React from "react";
import "./App.css";
import { FlashCards } from "./MultiplicationFlash";
function App() {
return (
<div className="App">
<header className="App-header">
<FlashCards />
@cellog
cellog / store.ts
Created September 2, 2019 15:41
Better types, with inference
interface Action<T = any> { type: T }
interface AnyAction extends Action { [extraProps: string]: any }
type Reducer<S = any, A extends Action = AnyAction> = (
state: S | undefined,
action: A
) => S
interface Store<
S = any,
@cellog
cellog / replaceReducer.ts
Created September 2, 2019 15:27
Buggy replaceReducer definition
replaceReducer<NewState = S, NewActions extends A = A>(
nextReducer: Reducer<NewState, NewActions>
): Store<NewState, NewActions>
@cellog
cellog / redux-types.ts
Last active August 30, 2019 20:00
Simplified Redux Types
interface Action<T = any> { type: T }
interface AnyAction extends Action { [extraProps: string]: any }
type Reducer<S = any, A extends Action = AnyAction> = (
state: S | undefined,
action: A
) => S
interface Store<S = any, A extends Action = AnyAction> {
getState(): S
@cellog
cellog / generic-inference2.ts
Created August 30, 2019 19:35
Non-Inferred Generics
// the example from typescript's docs
function getProperty<T, K extends keyof T>(obj: T, key: K) {
return obj[key];
}
interface FourLetters {
a: number
b: number
c: number
d: number