-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[v5] Remove observable replay #3877
[v5] Remove observable replay #3877
Conversation
🦋 Changeset detectedLatest commit: ddf64b6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit ddf64b6:
|
@GoldingAustin Do you know what can be done here to make |
I can't look at the Linear ticket but would love to understand the reasoning behind this change. I'm used to svelte store style observables so |
Often u might be interested to listen for a change. This might be different from UI-related needs where you might want to render a retrieved value immediately though. The point is that if you want to listen for a change then it's really quirky to ignore the first emitted value but when you want to combine change+current value... that is more straightforward to do. |
Thanks for explaining the reasoning @Andarist, I really appreciate the insight. I'm firmly over here in UI-land so this isn't a change I'm excited about but at least I understand it now. |
@tivac You're in luck; since // initial snapshot vvvvvvvvvvvvvvvvvvvvv
const state = readable(service.getSnapshot(), (set) => {
return service.subscribe((state) => {
if (state.changed) {
set(state);
}
}).unsubscribe;
}); I believe everything will still work the same, and you will have the initial snapshot available immediately regardless of these changes. It might even work better because you won't get a redundant update (two initial snapshots - one with |
I'm mostly subscribing to interpreters via |
It seems like the only failing tests are for The context is that |
I'll take a look at this today! |
This will be a quick fix; I'll remove the |
I think the new function export would be the best direction (cc. @Andarist) |
Yeah, I think that a new export is the best solution here - unless -const state = from(actor)
+const [state] = useActor(actor) A notable difference is that |
2ce6dbf
to
3c1886f
Compare
…tions (#3898) * Tweak changes related to dropping replaying of the last notifications * Remove unused import * Fixed Vue test * remove debugger
22a736e
to
0333b2f
Compare
82c6c98
to
ddf64b6
Compare
'xstate': major | ||
--- | ||
|
||
Observing an actor via `actor.subscribe(...)` no longer immediately receives the current snapshot. Instead, the current snapshot can be read from `actor.getSnapshot()`, and observers will receive snapshots only when a transition in the actor occurs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note for me - this might require a small tweak in the wording if we decide to go with #3912
This PR makes
actor.subscribe(...)
a hot observable; it will no longer emit the current snapshot, which can be retrieved synchronously viaactor.getSnapshot()
.