-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed an issue with
invoke.onDone
/invoke.onError
actions being in…
…correctly ignored (#388) * Fixed an issue with `invoke.onDone`/`invoke.onError` actions being incorrectly ignored * add test cases * add changeset
- Loading branch information
Showing
7 changed files
with
305 additions
and
7 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@xstate/tools-shared': patch | ||
'@xstate/cli': patch | ||
--- | ||
|
||
Fixed an issue that could result in loss of information about multiple actions within `invoke.onDone`/`invoke.onError` transitions. |
38 changes: 38 additions & 0 deletions
38
packages/shared/src/__tests__/__examples__/actor-ondone-multiple-actions.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { createMachine } from 'xstate'; | ||
|
||
const machine = createMachine( | ||
{ | ||
schema: { | ||
services: {} as { | ||
getData: { | ||
data: unknown; | ||
}; | ||
}, | ||
}, | ||
tsTypes: {} as import('./actor-ondone-multiple-actions.typegen').Typegen0, | ||
predictableActionArguments: true, | ||
|
||
initial: 'A', | ||
context: { | ||
value: '', | ||
}, | ||
states: { | ||
A: { | ||
invoke: { | ||
src: 'getData', | ||
onDone: { | ||
actions: ['actionA', 'actionB'], | ||
target: 'DONE', | ||
}, | ||
}, | ||
}, | ||
DONE: {}, | ||
}, | ||
}, | ||
{ | ||
actions: { | ||
actionA: () => {}, | ||
actionB: () => {}, | ||
}, | ||
}, | ||
); |
37 changes: 37 additions & 0 deletions
37
packages/shared/src/__tests__/__examples__/actor-ondone-single-action.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { createMachine } from 'xstate'; | ||
|
||
const machine = createMachine( | ||
{ | ||
schema: { | ||
services: {} as { | ||
getData: { | ||
data: unknown; | ||
}; | ||
}, | ||
}, | ||
tsTypes: {} as import('./actor-ondone-single-action.typegen').Typegen0, | ||
predictableActionArguments: true, | ||
|
||
initial: 'A', | ||
context: { | ||
value: '', | ||
}, | ||
states: { | ||
A: { | ||
invoke: { | ||
src: 'getData', | ||
onDone: { | ||
actions: 'actionA', | ||
target: 'DONE', | ||
}, | ||
}, | ||
}, | ||
DONE: {}, | ||
}, | ||
}, | ||
{ | ||
actions: { | ||
actionA: () => {}, | ||
}, | ||
}, | ||
); |
38 changes: 38 additions & 0 deletions
38
packages/shared/src/__tests__/__examples__/actor-onerror-multiple-actions.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { createMachine } from 'xstate'; | ||
|
||
const machine = createMachine( | ||
{ | ||
schema: { | ||
services: {} as { | ||
getData: { | ||
data: unknown; | ||
}; | ||
}, | ||
}, | ||
tsTypes: {} as import('./actor-onerror-multiple-actions.typegen').Typegen0, | ||
predictableActionArguments: true, | ||
|
||
initial: 'A', | ||
context: { | ||
value: '', | ||
}, | ||
states: { | ||
A: { | ||
invoke: { | ||
src: 'getData', | ||
onError: { | ||
actions: ['actionA', 'actionB'], | ||
target: 'ERROR', | ||
}, | ||
}, | ||
}, | ||
ERROR: {}, | ||
}, | ||
}, | ||
{ | ||
actions: { | ||
actionA: () => {}, | ||
actionB: () => {}, | ||
}, | ||
}, | ||
); |
37 changes: 37 additions & 0 deletions
37
packages/shared/src/__tests__/__examples__/actor-onerror-single-action.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { createMachine } from 'xstate'; | ||
|
||
const machine = createMachine( | ||
{ | ||
schema: { | ||
services: {} as { | ||
getData: { | ||
data: unknown; | ||
}; | ||
}, | ||
}, | ||
tsTypes: {} as import('./actor-onerror-single-action.typegen').Typegen0, | ||
predictableActionArguments: true, | ||
|
||
initial: 'A', | ||
context: { | ||
value: '', | ||
}, | ||
states: { | ||
A: { | ||
invoke: { | ||
src: 'getData', | ||
onError: { | ||
actions: 'actionA', | ||
target: 'ERROR', | ||
}, | ||
}, | ||
}, | ||
ERROR: {}, | ||
}, | ||
}, | ||
{ | ||
actions: { | ||
actionA: () => {}, | ||
}, | ||
}, | ||
); |
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
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