-
Notifications
You must be signed in to change notification settings - Fork 7
Allow for unimplemented actions/services/guards #32
Comments
Is there an example of what this would compile to? I haven't seen a XState machine like this I don't think. |
const machine = createMachine({
entry: ['helloWorld'],
}); In normal XState, you don't need to define every action that the machine describes. This is an important tool for leaving the implementation up to the 'consumer' of the machine, and I use it all the time |
Ah and then you define those by extending? Makes sense, think I can add this. |
Yeah you can define these when you |
I really like this idea. It overcomes one of the awkward things about Lucy at the moment, the interface between Lucy and JavaScript. This idea sidesteps the issue by making Lucy files purely descriptive. I'm wondering if we should maybe even encourage this pattern over importing JS. Will see how it looks once it's done. |
@matthewp I 100% agree. I also think Lucy would benefit from not exporting a machine, but exporting a
This is both more flexible in terms of Typescript (allows for generics) and provides first-class typings for actions/services/guards etc. EDIT: And also could make Lucy's syntax a lot simpler by removing/discouraging the use of 'use'. |
@oliverturner curious to hear your thoughts on this, if you have any. |
@mattpocock Can you open a separate issue to discuss your idea for changing what gets exported? I'm intrigued by the idea but want to keep this one focused on allowing unimplemented named guards and actions. |
For this issue I'm going to allow you to define a named guard or action without assigning a value like so:
In #34 we can talk about what an inline form would look like. |
Perfeito |
This is great, I was just about to open an issue for a feature request allowing |
@reaktivo you might want to look at #34 where this is better explained. Essentially we are changing machine signatures to be a function that takes in actions/guards, etc. and returns a StateMachine. The
Or with an inline form:
|
Closed by #41 41 |
Sometimes, actions/services/guards are best implemented not in the initial definition of the machine. Sometimes, it's best to leave them unimplemented until you use the machine in your frontend/backend code.
This means that Lucy would need to compile action definitions that aren't imported via
use
.The text was updated successfully, but these errors were encountered: