This file contains hidden or 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
| function Example() { | |
| const [{ isLoading, error, data }] = useMachine( | |
| createQuery('repoData', () => fetch('...').then((res) => res.json())) | |
| ); | |
| } |
This file contains hidden or 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 machine = Machine({ | |
| id: 'ATM', | |
| initial: 'idle', | |
| states: { | |
| idle: { | |
| on: { | |
| INSERT_CARD: 'authenticating', | |
| } | |
| }, | |
| authenticating: { |
This file contains hidden or 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 hidden or 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
| Machine({ | |
| id: 'donut', | |
| initial: 'ingredients', | |
| states: { | |
| ingredients: { | |
| on: { | |
| NEXT: 'directions', | |
| }, | |
| }, | |
| directions: { |
This file contains hidden or 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 hidden or 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 auth = Machine({ | |
| id: 'auth', | |
| initial: 'authenticating', | |
| states: { | |
| authenticating: { | |
| after: { | |
| 1000: 'authenticated' | |
| } | |
| }, |
This file contains hidden or 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 pongMachine = Machine({ | |
| initial: 'waiting', | |
| states: { | |
| waiting: { | |
| on: { | |
| PING: { | |
| actions: sendParent('PONG', { delay: 1000 }) | |
| } | |
| } | |
| } |
This file contains hidden or 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 A1 = () => console.log('Action A1'); | |
| const machine = Machine({ | |
| initial: 's1', | |
| states: { | |
| h: { type: 'history' }, | |
| s1: {on: {E11: 's2'}}, | |
| s2: {on: {E11: 's3'}}, | |
| s3: {on: {E11: 's4'}}, | |
| s4: {/* ... */} |
This file contains hidden or 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 hidden or 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
| Machine({ | |
| id: 'planet', | |
| initial: 'unknown', | |
| states: { | |
| unknown: { | |
| on: { | |
| PROBE: 'probing', | |
| }, | |
| }, | |
| probing: { |
NewerOlder