I have a state called "Attract mode" which has an "entry" event defined like this:
entry: {
type: "instructDisplays",
params: {
layout: "attract",
},
},
For the code that implements the action, I chose "emit", and of course I get something like this:
export default emit({
type: 'instructDisplays'
})
Which is all fine, but I don't seem to have any access to the params I set for the action.
If I define the action a bit differently, it seems I can access the params, but then the call to emit seems to do nothing!
actions: {
instructDisplays: (_, params: { layout: string }) => {
console.log("should emit now...", params);
emit({
type: "instructDisplays",
layout: params.layout
});
},
// instructDisplays: emit({ type: "instructDisplays" }),
},
When I subscribe to events as before, I see the console.logs "should emit now", etc., but not "instructDisplays event" as below:
root.on("instructDisplays", (event) => {
console.log("instructDisplays event:", event);
})
What am I missing about actions and their params, especially when relating to emit ?