Search code examples
angulartypescriptobservable

Angular setting behaviourSubject default value is not working as expected


Lets say i have som behaviour subject with boolean type. And I want that boolean to be true on init.

private _someBool: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(true);
get someBool$() {
    return this._someBool.asObservable();
}

But the problem is that when I subscribe to it the value is false and I have no idea why. How can i set default value when this approach does not work?


Solution

  • It was my mistake there was really place where i was setting it.