01/30/2021, Sat
Logical Evaluation
In traditional JavaScript, one would use the logical operators "&&", "||", "!" when evaluating variables for the "and", "or", and "not" conditions respectively.
Similarly, there are RxJS operators which looks like the ones found in JavaScript when you wish to treat observable like values that needs to be compared against one another.
For the examples below, "true" in this sense refers to the observable have "truly" emitted a value and not have it base upon the actual underlying value within the observable.
AND
Use the "forkJoin" operator when every single observable must be activated for the subscription to run.
// When the observables will emit at least once in any order
import { forkJoin, of, interval } from 'rxjs';
import { take } from 'rxjs/operators';
const timer$ = interval(1000).pipe(take(1)),
truthfulness$ = of(true);
forkJoin([
timer$,
truthfulness$
])
.subscribe(() => {
console.log('All completed once');
});
Alternatively, you might be able to use "combineLatest" when you
have long-lived observables. Tangentially, "concat" or "zip" will work if a strict order needs to be imposed for activation of observables in a series.