Svelte integration #1324
-
Hi. I'm making a Svelte version of
Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
Awesome, looking forward to it! Options are merged in, but it's done within public withConfig(
options: Partial<MachineOptions<TContext, TEvent>>,
context: TContext | undefined = this.context
): StateNode<TContext, TStateSchema, TEvent, TTypestate> {
const { actions, activities, guards, services, delays } = this.options;
return new StateNode(
this.config,
{
actions: { ...actions, ...options.actions },
activities: { ...activities, ...options.activities },
guards: { ...guards, ...options.guards },
services: { ...services, ...options.services },
delays: { ...delays, ...options.delays }
},
context
);
}
Good question. If it's a "component-level" service (only active for the lifetime of the component), yes, it needs to be stopped if the component is no longer using it. Otherwise, it doesn't need to be stopped, as it's assumed something else manages the lifecycle of the service. |
Beta Was this translation helpful? Give feedback.
-
FWIW, I saw David's tweet about this discussion and wanted to mention that I also have a version of xstate-svelte (inspired by the react hooks). Feel free to take a look and take what you need if there's something useful there. Here's the link to the repo |
Beta Was this translation helpful? Give feedback.
Awesome, looking forward to it!
Options are merged in, but it's done within
machine.withConfig(...)
: