Skip to content

Instantly share code, notes, and snippets.

@rjdestigter
rjdestigter / machine.js
Last active March 7, 2020 14:13
Generated by XState Viz: https://xstate.js.org/viz
const canSubmit = ctx => !!(ctx.username && ctx.password && ctx.companyId)
const commonActions = {
CLICK_COMPANY_ID: "companyId",
CLICK_USERNAME: "username",
CLICK_PASSWORD: "password",
CLICK_OUTSIDE: "nothingHasFocus",
CLICK_LOGIN: [
{
@rjdestigter
rjdestigter / machine.js
Created March 11, 2020 19:20
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@rjdestigter
rjdestigter / machine.js
Created March 12, 2020 00:05
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
BMS
Home
routeToLogin -> Login
routeToSignUp -> SignUp
routeToHIW -> HowItWorks
routeToTC -> TermsAndConditions
routeToPP -> PrivacityPolicy
Login
clickUsername -> Username
@rjdestigter
rjdestigter / machine.js
Last active March 20, 2020 13:49
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@rjdestigter
rjdestigter / machine.js
Last active March 20, 2020 13:59
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@rjdestigter
rjdestigter / machine.js
Last active March 31, 2020 17:32
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@rjdestigter
rjdestigter / machine.js
Last active September 7, 2020 17:40
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
type IsNumber<A extends string> = A extends `${Digit}${infer T}` ? T extends "" ? true : IsNumber<T> : false
type NaN = "NaN"
type ToLiteralNumber<T extends string> = IsNumber<T> extends true ? MkTuple<T> extends true[] ? MkTuple<T>['length'] : NaN : NaN
type MkTuple<N extends string | number, T extends true[] = []> = `${T['length']}` extends `${N}` ? T : MkTuple<N, [true, ...T]>
type Add<A extends number, B extends number> = [...MkTuple<A>, ...MkTuple<B>]['length']
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions