-
Notifications
You must be signed in to change notification settings - Fork 3k
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
BehaviorSubject.getValue() always returns initial value if subscribed to observable from Webpack library #5105
Comments
Hi es-repo. I made a pull request to your reproduction that adds a working example that uses an app local source. |
Thanks, samal! |
Who use to subscribe with other observable ? const subject2 = new BehaviorSubject(undefined);
interval(1000).subscribe(subject2); I don't think this is a correct usage and even i don't know what will happen that way passing observable directly as a subscription. const subject2 = new BehaviorSubject(undefined);
interval(1000).pipe(mergeMap(() => subject2)).subscribe(console.log)
subject2.next(true) |
const subject2 = new BehaviorSubject(undefined);
interval(1000).subscribe(subject2); @Stradivario sorry, could you elaborate what do you mean? |
Never seen such a composition of observables i am really sorry if i miss understood it. I just prefer different approach of composing with pipe. My subscribe method is the last thing that i will write even i try to not write subscribe in my code. That's a different scenario and mind set which doesn't belong to me and i will try to get the best from it. Regards and Merry Christmas, |
This is a bug, but it cannot easily be fixed. The problem is that the subject isn't seen as a safe/trusted subscriber because the interop source won't see the per-package And that means that the subject will be 'cloned' so that an rxjs/src/internal/Subscriber.ts Lines 189 to 193 in f8a4876
And that means the the subject's original state will remain unchanged - the bug you reported. |
* test: add failing test for ReactiveX#5105 * chore: skip test and add a comment * chore: kick CI ... yet again
* test: add failing test for ReactiveX#5105 * chore: skip test and add a comment * chore: kick CI ... yet again
(methods we cannot use anyway see ReactiveX/rxjs#5105 vs. kombo's old getState())
Is there any way to work around it —while still transpiling w/ Webpack— without resorting to using another kind of |
@cartant isn't this handled now in the beta version? |
* chore: Stop skipping valid test Resolves #5105 * chore: Add comment about why this test is skipped. * chore: Correct skipped tests - Some of the skipped tests were clearly copied from retryWhen but never updated appropriately. - One of the skipped tests showed a buggy behavior that is now reported in an issue and a comment with a link to that issue is now above it. * chore: Update skipped tests - Uncomments a skipped test that was fixed with the v7 refactor (apparently just via better architecture) - Adds an additional test to simplify the same assertion - Adds a comment above a skipped section of tests explaining that we can probably remove them in v8 after we've moved completely to newer multicasting paradigms and removed deprecated operators. Resolves #5370 * chore: Stops skipping a fixed test. * chore: Add commented out bit to help find skipped tests Figuring out what tests are skipped out of 3,000+ tests is pretty annoying. I want to leave this here as a sign post to help.
Bug Report
Current Behavior
BehaviorSubject.getValue() always returns initial value if subscribed to an observable from Webpack library while the observable is emitting new values.
Reproduction
-Minimum code which reproduces bug:
https://github.com/es-repo/bug-repro/tree/master/rxjs/behavior-subject-and-observable-from-lib
Run "npm start" from within the "app" folder or open this link https://es-repo.github.io/bug-repro/rxjs/behavior-subject-and-observable-from-lib/app/dist/. And open console.
Code from the "app" which reproduces the issue:
Code from the "lib":
Console output:
Observable from lib: value=undefined getValue()=undefined
Observable from app: value=undefined getValue()=undefined
Observable from lib: value=0 getValue()=undefined
Observable from app: value=0 getValue()=0
Observable from lib: value=1 getValue()=undefined
Observable from app: value=1 getValue()=1
...
Expected behavior
BehaviorSubject.getValue() should return last value emitted from Observable.
Environment
Additional context
Related issue: #5051
The text was updated successfully, but these errors were encountered: