Same service, but different actions #2330
Unanswered
sebastienbarre
asked this question in
General
Replies: 1 comment 8 replies
-
The service is the instance. You create different instances by making separate const service1 = interpret(machine); // default actions
const service2 = interpret(machine.withConfig({
actions: {/* other actions */}
}); |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
To quote the doc: "Actions are fire-and-forget effects. For a machine to be useful in a real-world application, effects need to occur to make things happen in the real world, such as rendering to a screen."
Why is it therefore not possible to create two instances of a machine service with different actions?
As a use case, I want to share the same service between two different UI component, but with different side effects for each UI component...
Thanks
Beta Was this translation helpful? Give feedback.
All reactions