ReactiveX / rxjs

A reactive programming library for JavaScript
https://rxjs.dev
Apache License 2.0
30.7k stars 3k forks source link

BehaviorSubject created with "create" does not have getValue() method #1890

Closed acheshkov closed 5 years ago

acheshkov commented 8 years ago

RxJS version: 5.0.0-beta.9

Code to reproduce:

` var a = new Rx.BehaviorSubject('start');

var b = Rx.BehaviorSubject.create(a, new Rx.Observable(o => { a.subscribe(o); }));

console.log(b.getValue());

`

Expected behavior: // output: start

Actual behavior:

Uncaught TypeError: getValue is not a function

Additional information:

kwonoj commented 8 years ago

yes, behaviorSubject does not override create so it doesn't return instance of behaviorsubject. @blesh is this intended, or just oversight that need to be updated?

edited: looking into RxJS4 impl, it seems create is not expected to be exposed to behaviorSubject or some other variants.

jayphelps commented 8 years ago

To me, this seems like a similar problem to https://github.com/ReactiveX/rxjs/issues/1876 and https://github.com/ReactiveX/rxjs/issues/1829 with static operators not deferring to the current class type.

We may decide that subjects do not have these static operators on principle, but technically speaking I think it might be valuable if we could support it.

kwonoj commented 8 years ago

so suggestions to support variant of creation method as similar to of or etcs? I'm ok with that PR was created for simple alignment of interfaces (and at least get rid of unexpected creation method behavior).

jayphelps commented 8 years ago

I'm personally OK with accepting your https://github.com/ReactiveX/rxjs/pull/1894 PR to fix this bug and then add new functionality later, if we choose to do so. That seems like a much longer conversation and I don't want it to block v5.0.0 release.

kwonoj commented 8 years ago

I'm personally OK with accepting your #1894 PR

: makes sense, let's continue discussion in PR if it's acceptable or not (including details of implementation as well). We could leave this issue opened for further goals if PR's agreed to check in.

benlesh commented 8 years ago

This was an oversight. It should have the same arguments as the constructor and return a BehaviorSubject

benlesh commented 5 years ago

create static methods are going away. This is obsolete.