Skip to content

Is <ActorRef>.state.context safe to use? #1759

Answered by davidkpiano
Sheldonfrith asked this question in Q&A
Discussion options

You must be logged in to vote

It's "fine" in v4, but the downside is requiring you to know the implementation details of the ActorRef in order to "reach in" and get the state.

In v5, there will likely be a standard API for getting the "state snapshot" of an actor:

-Parent.state.context.actorRef.state.context
+Parent.state.context.actorRef.getSnapshot().context

That way, it won't matter what "kind" of actor the actorRef is (whether it's spawned from a promise, observable, something else...), you'll be able to get the most recently emitted state from .getSnapshot().

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Sheldonfrith
Comment options

Answer selected by Sheldonfrith
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants