What strategy should be used to initialize an actor state asynchronously? #145
Answered
by
ncthbrt
tylerhjones
asked this question in
Q&A
-
For example the initialStateFunc is: initializeState () {
if (this.initialStateFunc) {
try {
this.state = this.initialStateFunc(this.createContext(undefined));
} catch (e) {
this.handleFault(undefined, undefined, e);
}
} else {
this.state = this.initialState;
}
} I want to create an actor which is wrapping a document the user edits. My store for this document acts asynchronously, so how can I ensure that messages sent to this actor will be acting on the latest version of the inner document? |
Beta Was this translation helpful? Give feedback.
Answered by
ncthbrt
Jun 7, 2024
Replies: 1 comment 2 replies
-
Are you using nact or @nact/core? The latter supports async init functions. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alternatively, you could dispatch a message immediately after creating the actor inside the initialStateFunction (as context is available). This would guarantee that the message would be processed first