You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! I write to ask help for finding a solution.
I have an Obs (produceObs) that is zipped with another (consumeObs), so that value is emitted only when a consume message is send (within consumeObs). In this way a queue of to-be-emitted values creates (within the produeObs). What I would like to do, at some point, is to check wheter in produceObs I have some kind of values, even if they have not yet consumed. Can I do that?
I tried to solve using find with this stackblitz, but without success: the operator returns only when the values I look for are consumed.
Here is the main code
var messageConsumed = new Subject<string>();
var enqueuedMessage = new Subject<string>();
function read() {
emit('read');
}
function write() {
emit('write');
}
function emit(s: string) {
enqueuedMessage.next(s);
}
function consume() {
messageConsumed.next('');
}
messageConsumed
.pipe(zip(enqueuedMessage.pipe(filter((x) => x != null))))
.pipe(concatMap((x) => of(x).pipe(delay(100))))
.subscribe((message) => {
console.log(message);
});
function find2() {
enqueuedMessage
.pipe(
find((x) => x == 'write'),
take(1)
)
.subscribe((x) => {
console.log(x == undefined ? 'not found' : 'found!');
});
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello! I write to ask help for finding a solution.
I have an Obs (
produceObs
) that is zipped with another (consumeObs
), so that value is emitted only when a consume message is send (withinconsumeObs
). In this way a queue of to-be-emitted values creates (within theprodueObs
). What I would like to do, at some point, is to check wheter inproduceObs
I have some kind of values, even if they have not yet consumed. Can I do that?I tried to solve using
find
with this stackblitz, but without success: the operator returns only when the values I look for are consumed.Here is the main code
Beta Was this translation helpful? Give feedback.
All reactions