admin管理员组文章数量:1123775
I am trying to do something like this...
checkingSession: {
entry: () => console.log('Entered Checking status state'),
invoke: {
src: checkSession,
input: ({context}) => ({
auth0Client: context.auth0Client
}),
onDone: [
{
target: 'authenticated',
cond: (_, event) => {
console.log(`This user is authenticated ${event.output.isAuthenticated}`);
return event.output?.isAuthenticated
},
actions: ({context, event}) => {
console.log("This does work "+event.output.isAuthenticated)
context.user = event.output.user;
context.isAuthenticated = event.output.isAuthenticated;
}
},
{
target: 'notAuthenticated'
}
],
onError: {
target: 'error',
actions: assign({
error: (_, event) => event.error?.message || 'Failed to check session'
})
}
}
},
notAuthenticated: {
entry: () => console.log('Entered notAuthenticated state'),
on: {
LOGIN: 'authenticating'
}
},
authenticated: {
entry: () => console.log('Entered authenticated state'),
on: {
LOGOUT: 'loggingOut',
REFRESH: 'refreshing'
}
},
}
The problem is the cond:
doesn't seem to work for example the console log says...
Entered Checking status state
index.js:23 Checking session...
index.js:85 This does work false
index.js:130 Entered authenticated state
so how do I do a proper guard in an onDone
section?
本文标签: xstateHow do I do a guard in OnDone on XState5Stack Overflow
版权声明:本文标题:xstate - How do I do a guard in OnDone on XState5? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736595227a1945137.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论