-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix send type for useActor * Add file to test * Update .changeset/honest-tools-shave.md Co-authored-by: Mateusz Burzyński <[email protected]> * Add test --------- Co-authored-by: Mateusz Burzyński <[email protected]>
- Loading branch information
1 parent
39702e6
commit f112081
Showing
4 changed files
with
47 additions
and
2 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,5 @@ | ||
--- | ||
'@xstate/vue': patch | ||
--- | ||
|
||
Fix `send(…)` type for `useActor(…)` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<template> | ||
<button data-testid="count" @click="send({ type: 'INC' })"> | ||
{{ snapshot.context }} | ||
</button> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { useActor } from '../src/index.ts'; | ||
import { fromTransition } from 'xstate/actors'; | ||
import { defineComponent } from 'vue'; | ||
const reducer = (state: number, event: { type: 'INC' }): number => { | ||
if (event.type === 'INC') { | ||
return state + 1; | ||
} | ||
return state; | ||
}; | ||
const logic = fromTransition(reducer, 0); | ||
export default defineComponent({ | ||
setup() { | ||
const { snapshot, send } = useActor(logic); | ||
return { snapshot, send }; | ||
} | ||
}); | ||
</script> |
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