Did I understand correctly that onDone and onError are the keys that have to be used for those actions, as in the keys are the convention XState relies on?
And what happens if they are not provided?
Yes, onDone and onError are properties of XState. They are handling the events of whatever you are invoking. When invoking a promise, the only two events you can have are fulfilled or rejected.
With a normal event, you also specify a target and actions.
Did I understand correctly that
onDone
andonError
are the keys that have to be used for those actions, as in the keys are the convention XState relies on?And what happens if they are not provided?
Yes,
onDone
andonError
are properties of XState. They are handling the events of whatever you are invoking. When invoking a promise, the only two events you can have are fulfilled or rejected.With a normal event, you also specify a target and actions.
The event handlers of the service use the exact same syntax to specify the next state and actions to take.
onError
andonDone
are both optional so you can totally omit them for "fire and forget" services.You can read more about the invoke property here which also explains some properties I haven't covered :)