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 { Observable } from "rxjs"; | |
import { map } from "rxjs/operators"; | |
import { Required } from "utility-types"; | |
import { createMachine, sendParent, assign, spawn, Actor } from "xstate"; | |
import { $YesReallyAny, assert } from "../"; | |
import { QueryResult } from "../gql/queryResultHandler"; | |
let id = 0; | |
enum 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
type Events = | |
| { type: "LOG_IN" } | |
| { type: "LOG_OUT" } | |
| { type: "CHECK_TOKEN_VALID" } | |
| { type: "CHECK_TOKEN_INVALID" } | |
| { type: "AUTHORIZE_OK" } | |
| { type: "AUTHORIZE_DENIED" }; | |
const machine = createMachine<{}, Events>({ | |
id: "main-auth-spec", |
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
var Actions; | |
(function (Actions) { | |
Actions["storeRefreshToken"] = "storeRefreshToken"; | |
Actions["removeRefreshToken"] = "removeRefreshToken"; | |
})(Actions || (Actions = {})); | |
var Services; | |
(function (Services) { | |
Services["checkToken"] = "checkToken"; | |
Services["performOauthFlow"] = "performOauthFlow"; | |
Services["retrieveTokens"] = "retrieveTokens"; |
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
type TContext = { | |
state: { | |
someComputedReduxState: string | |
}, | |
actions: { | |
doTheThing: () => void | |
} | |
} | |
const Context = React.createContext<TContext | null>(null); | |
function Provider(props) { |
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 { useMachine } from "@xstate/react/lib"; | |
import { GraphQLError } from "graphql"; | |
import { values } from "lodash"; | |
import React, { useEffect, useRef } from "react"; | |
import { Observable } from "rxjs"; | |
import { map } from "rxjs/operators"; | |
import { assign, createMachine } from "xstate"; | |
import { QueryResultContainer, QueryWrapper } from "../gql/queryResultHandler"; | |
import { $YesReallyAny, assert } from "../index"; |
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 { isArray, some } from "lodash"; | |
import { Observable } from "rxjs"; | |
import { useObservable } from "rxjs-hooks"; | |
import { | |
interpret, | |
EventObject, | |
StateMachine, | |
Typestate, | |
StateSchema, | |
Interpreter, |
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 RepositoryMachine = Machine({ | |
key: "repository", | |
initial: "noRepositorySelected", | |
states: { | |
noRepositorySelected: { | |
on: { | |
REPOSITORY_SELECTED: { | |
target: "viewingChanges", | |
actions: assign({ | |
selectedRepository: (_ctx, event) => event.repository |
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 { useMachine } from "@xstate/react/lib"; | |
import { assign, createMachine } from "xstate"; | |
import { uniqueId } from "lodash"; | |
import React from "react"; | |
import { makeMachineRoutable } from "./makeMachineRoutable"; | |
type PromiseContext<TData, TParameters> = { | |
parameters?: TParameters; |
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 { StateMachine, StateSchema, EventObject, Typestate, Interpreter, State } from "xstate"; | |
import * as _ from "lodash"; | |
import React, { useContext } from "react"; | |
export function makeMachineRoutable< | |
TContext, | |
TStateSchema extends StateSchema, | |
TEvent extends EventObject, | |
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
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
0 ldc #2 <foo> | |
2 astore_1 | |
3 new #7 <java/lang/StringBuilder> | |
6 dup | |
7 invokespecial #8 <java/lang/StringBuilder.<init>> | |
10 aload_1 | |
11 invokevirtual #9 <java/lang/StringBuilder.append> | |
14 ldc #23 <, bar> | |
16 invokevirtual #9 <java/lang/StringBuilder.append> | |
19 invokevirtual #12 <java/lang/StringBuilder.toString> |