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
// API of the search prop is based on React's setState API | |
// crp stands for "create redirect params" | |
type O = Record<string, any> | |
type CrpBase = { | |
pathname: string | |
status: number | |
} | |
type CrpObj = CrpBase & { search: O } | |
type CrpFunc = CrpBase & { |
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
// API of the search prop is based on React's setState API | |
// crp stands for "create redirect params" | |
type O = Record<string, any> | |
type CrpBase = { | |
pathname: string | |
status: number | |
} | |
type CrpObj = CrpBase & { search: O } | |
type CrpFunc = CrpBase & { |
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 { Machine } from "xstate" | |
import Auth from "@aws-amplify/auth" | |
import { Hub } from "@aws-amplify/core" | |
import { sentry } from "../sentry" | |
import { queryCache } from "react-query" | |
// Some of the events from the Hub auth channel are in the documentation here | |
// https://docs.amplify.aws/lib/auth/auth-events/q/platform/js | |
// Even more events in the source code | |
// https://github.com/aws-amplify/amplify-js/blob/92d8d800256119d1ba84bb90097f91a983b1e5c0/packages/auth/src/Auth.ts |
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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
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
const gathering = Machine({ | |
id: "gathering", | |
initial: "started", | |
states: { | |
started: { | |
entry: (ctx, e) => console.log('"Started" entry action executed'), | |
exit: (ctx, e) => console.log('"Started" exit action executed'), | |
on: { | |
SAME_SAME: { | |
target: "started", |
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
const birthday = Machine({ | |
id: "birthday", | |
initial: "notStarted", | |
states: { | |
started: { | |
initial: "boring", | |
entry: (ctx, e) => console.log('Parent entry action executed'), | |
exit: (ctx, e) => console.log('Parent exit action executed'), | |
on: { | |
CAKE_BONANZA: { |
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
// There must be exactly one initial state, which implies | |
// there must be at least one finite state. | |
// const dullHuman = Machine({ | |
// id: 'dullHuman', | |
// initial: 'idle', | |
// states: { | |
// idle: {} | |
// } | |
// }) |
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
// * Stubbed out methods so we can copy the machine to the xstate visualizer | |
const fetchAll = () => {} | |
const setRemoteData = () => {} | |
const isDeselectingLastSelectedItem = () => {} | |
const selectMenuItem = () => {} | |
const deselectMenuItem = () => {} | |
const isNotCreated = (ctx, e) => false | |
const isNotYetActive = (ctx, e) => false | |
const hasOrderedAndIsActive = (ctx, e) => false | |
const hasOrderedAndIsExpired = (ctx, e) => false |
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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
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
const dogFetcherMachine = Machine({ | |
id: "dog fetcher", | |
initial: "idle", | |
context: { | |
dog: null, | |
error: null | |
}, | |
states: { | |
idle: { | |
on: { FETCH: "loading" } |
NewerOlder