Say I have a behavior subject, piped through an operation or two:
const inputNumber = new BehaviorSubject(2);
// The current number can be retrieved with `inputNumber.getValue()`
const numberAfterOperations = inputNumber.pipe(
filter(a => (a+1) % 2), // filter out odd numbers
map(a => a * a), // square it
);
How can I access the value of numberAfterOperations?
// Does not work because `getValue` is not defined!
numberAfterOperations.getValue(); // I expect this to be 4
inputNumber.next(4);
// Does not work!
numberAfterOperations.getValue(); // I expect this to be 16
Note: the observable subscription here works fine. I'm asking about synchronous access to the
.value
(or.getValue()
)
I noticed a similar issue here, but did not see a resolution: https://github.com/ReactiveX/rxjs/issues/2378