Skip to content

Instantly share code, notes, and snippets.

@willmcclellan
Created June 8, 2021 03:50
Show Gist options
  • Save willmcclellan/21e6d4e89357413b99a4b3ac7869a46b to your computer and use it in GitHub Desktop.
Save willmcclellan/21e6d4e89357413b99a4b3ac7869a46b to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const groupMachine = Machine({
id: 'group',
initial: 'active',
context: {
"totalUserCount": 1,
"expiredCount": 0,
"roleId": "",
"nextStartAt": "2021-06-08T11:00:00.000Z",
"expiresAt": "",
"userId": "6064bd8fb28e8d22a6f8d96e",
"expiredAt": "2021-04-07T12:11:10.367Z",
"templateId": "6064bba0b28e8d54d0f8d33c",
"nextDueAt": "2021-06-08T11:34:59.999Z",
"createdAt": "2021-04-07T11:36:10.564Z",
"totalRoleCount": 1,
"updatedAt": "2021-06-07T19:00:10.802Z",
"locationId": "6064de3cfb44733b75163d19"
},
states: {
active: {
on: {
EXPIRED: 'expired',
RESOLVED: 'resolved',
}
},
expired: {
entry: ['expire'],
on: {
EXPIRED: 'expired',
RESOLVED: 'resolved',
}
},
resolved: {
entry: ['resolve'],
type: 'final'
},
},
}, {
actions: {
expire: assign({
expiredCount: (context, event) => {
console.log('hello')
return context.expiredCount + 1
}
}),
resolve: assign({
expiredCount: (context, event) => 0
}),
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment