-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[v5] Routable states #4184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+618
−1
Merged
[v5] Routable states #4184
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
316edcb
Add route + tests
davidkpiano df8ed86
Add route tests
davidkpiano 4c83916
Merge branch 'main' into v5/routes
davidkpiano b36eb37
Fix types
davidkpiano f5307a9
Merge branch 'main' into v5/routes
davidkpiano abb56ec
Merge branch 'main' into v5/routes
davidkpiano 1b6346e
Merge branch 'main' into v5/routes
davidkpiano d0f66d1
Fix types
davidkpiano 447e978
One down
davidkpiano 2b66bc4
Default to typegen disabled
davidkpiano b134d0d
Remove stuff
davidkpiano 4378324
More progress
davidkpiano 1f56ae7
Some surgery
davidkpiano f428bf1
Actors
davidkpiano 3778177
This is fun
davidkpiano 4c8202c
This is fun
davidkpiano 480b646
More deletion
davidkpiano 2ade975
Remove ResolveTypegenMeta type param
davidkpiano 752b50a
Renaming
davidkpiano b657858
Cleanup
davidkpiano 24104b5
Remove typgenTypes files + mentions
davidkpiano 3158807
Merge branch 'main' into davidkpiano/remove-typegen-1
davidkpiano 7410d0a
Simplification
davidkpiano e71693b
Rename TResolvedTypesMeta -> TTypes
davidkpiano 99843ed
More simplification
davidkpiano 751f7e0
Strongly type meta keyes
davidkpiano 4022c9c
Merge branch 'main' into v5/routes
davidkpiano 22ae7b7
Merge branch 'main' into davidkpiano/getmeta-typed
davidkpiano cc83948
Add test
davidkpiano 6de31d3
Clean up State
davidkpiano 6e6950b
Merge branch 'main' into v5/routes
davidkpiano 38041c3
Merge branch 'davidkpiano/getmeta-typed' into v5/routes
davidkpiano 6c4843e
Consistency: use full state IDs
davidkpiano ca80978
Strongly type route events
davidkpiano 4e3a800
Merge branch 'main' into v5/routes
davidkpiano 4893ba6
Merge branch 'main' into v5/routes
davidkpiano 2604d70
Merge branch 'main' into v5/routes
davidkpiano 1a4b773
Merge branch 'main' into v5/routes
davidkpiano 69de11b
Merge branch 'main' into v5/routes
davidkpiano db3f8fa
Deep routing
davidkpiano a028ff8
Changeset
davidkpiano 9d02e91
Route by id with single event type
davidkpiano cf31cfd
Remove reenter prop
davidkpiano 4e09eed
Move route transition formatting to root
davidkpiano 65fb9e6
Update packages/core/src/types.ts
davidkpiano 01d3fff
Update routable states to use '#' prefix for navigation and adjust re…
davidkpiano 2788fb2
Add test
davidkpiano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| --- | ||
| 'xstate': minor | ||
| --- | ||
|
|
||
| Added routable states. States with `route: {}` and an explicit `id` can be navigated to from anywhere via a single `{ type: 'xstate.route', to: '#id' }` event. | ||
|
|
||
| ```ts | ||
| const machine = setup({}).createMachine({ | ||
| id: 'app', | ||
| initial: 'home', | ||
| states: { | ||
| home: { id: 'home', route: {} }, | ||
| dashboard: { | ||
| initial: 'overview', | ||
| states: { | ||
| overview: { id: 'overview', route: {} }, | ||
| settings: { id: 'settings', route: {} } | ||
| } | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| const actor = createActor(machine).start(); | ||
|
|
||
| // Route directly to deeply nested state from anywhere | ||
| actor.send({ type: 'xstate.route', to: '#settings' }); | ||
| ``` | ||
|
|
||
| Routes support guards for conditional navigation: | ||
|
|
||
| ```ts | ||
| settings: { | ||
| id: 'settings', | ||
| route: { | ||
| guard: ({ context }) => context.role === 'admin' | ||
| } | ||
| } | ||
| ``` |
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
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.