-
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
Behaviour getValue functionality missing #758
Comments
I think it's breaking supposed way of reactive paradigm. Can you describe your specific case? Maybe there's better way to solve this problem. |
Yes (and no). FWIW, you could examine that in previous versions as well. most of the time you shouldn't be using this though, but there are situations were it can come in handy. So:
Fair? |
My (potentially edge!) use case involves a source of deltas to a data structure. In order to apply the delta I need a reference to the existing data structure. E.g. - private _x: BehaviorSubject<IX[]> = new BehaviorSubject([]);
get x() : Observable<IX[]> {
return this._x;
}
private apply(delta: Delta<IX>): void {
delta(this._x.value); // invalid access to private member
} The commit which changes it from public to private doesn't provide any context. My options are to -
Any pointers to alternative approaches would be much appreciated. Also, FWIW I would rather see it be implemented as (happy to make a PR) - import {Subject} from '../Subject';
import {Subscriber} from '../Subscriber';
import {Subscription} from '../Subscription';
export class BehaviorSubject<T> extends Subject<T> {
constructor(private _value: T) {
super();
}
_subscribe(subscriber: Subscriber<any>): Subscription<T> {
const subscription = super._subscribe(subscriber);
if (!subscription) {
return;
} else if (!subscription.isUnsubscribed) {
subscriber.next(this._value);
}
return subscription;
}
_next(value: T): void {
super._next(this._value = value);
}
get value(): T {
return this._value;
}
} |
BehaviorSubject's |
I don't like a completely public value because it can then be set without I was thinking that hiding it behind either a I suppose the big advantage in both cases is to be more expressive about Hm, I think I've managed to talk myself around 360 back to the On Mon, 23 Nov 2015 23:11 Ben Lesh notifications@github.com wrote:
|
All I know is it's available via |
@Blesh calling
Simply exposing |
Okay... |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Is the
value
property of BehaviourSubject supposed to be public? Or is there supposed to be a publicgetValue
function like there is in the previous version?There is currently no way of reading the value without subscribing.
The text was updated successfully, but these errors were encountered: