Closed Simonl9l closed 1 year ago
You're welcome! I'll definitely support xstate v5 :)
https://github.com/wobsoriano/pinia-xstate/tree/xstate-v5
You can try using npm install pinia-xstate@2.0.0-beta.0
@wobsoriano thanks for looking into this, and setting up a new npm beta package...
I did try to instal but get this error:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: website@0.0.0
npm ERR! Found: xstate@5.0.0-beta.27
npm ERR! node_modules/xstate
npm ERR! xstate@"5.0.0-beta.27" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer xstate@"^5.0.0" from pinia-xstate@2.0.0-beta.0
npm ERR! node_modules/pinia-xstate
npm ERR! pinia-xstate@"2.0.0-beta.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
the latest beta xstate version is "xstate": "5.0.0-beta.27"
I'd assume (I have no clue on this stuff) you'd need to make the peer dependency be something like "xstate": "^5.0.0-beta.27"
than "xstate": "^5.0.0"
?
I can help out with this if needed; please let me know.
Hey @davidkpiano, that would be nice!
would it be at all complex to also include the ability to initialize the actor with input?
@Simonl9l It's not documented, but you can do that by passing in a 2nd param to the middleware:
const interpreterOptions = {
input: {
userId: '123',
defaultRating: 5,
}
}
export const useToggleStore = defineStore(
toggleMachine.id,
xstate(toggleMachine, interpreterOptions)
)
Feel free to try again npm install pinia-xstate@2.0.0-beta.1
. Thanks!
Hi @wobsoriano --- not sure we have this set yet?
npm install pinia-xstate@2.0.0-beta.1
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: website@0.0.0
npm ERR! Found: xstate@5.0.0-beta.27
npm ERR! node_modules/xstate
npm ERR! xstate@"5.0.0-beta.27" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer xstate@"^5.0.0-beta.28" from pinia-xstate@2.0.0-beta.1
npm ERR! node_modules/pinia-xstate
npm ERR! pinia-xstate@"2.0.0-beta.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
Might be a cache issue? Worked for me:
Great to have this package available. Thanks!
Do you have plans to support the https://github.com/statelyai/xstate/tree/next version of xState?
There is a migration guide here
Also if one has child or spawned state machines will the package also ensure the state of those machines are persisted to pinia too?
Whilst it's in beta it would be great to have a matching beta pina-xstate package...!
Given pinia's use case perhaps this is something that the xstate maintainers would bring into the fold of their packages?
Thanks again!