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
I new in Rxjs. I spend several day learn it, and now trying to implement a queue sending message with it. In my code i want to send a message every 5 seconds, like this:
interval(5000)
.pipe(
map(() => {
if (this._queue.length > 0) {
const turn = this._queue[0]
this._queue.shift() // remove the first element
return turn
}
})
)
.subscribe( data => {
if (data !== undefined ) {
this._transmitter.sendMessage(data.targetID, data.message)
}
})
It's working properly, but is this the right way? Or anyone can tell me how best practice to use rxjs for queue.
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
-
I new in Rxjs. I spend several day learn it, and now trying to implement a queue sending message with it. In my code i want to send a message every 5 seconds, like this:
It's working properly, but is this the right way? Or anyone can tell me how best practice to use rxjs for queue.
I'm so sorry about my grammar
Beta Was this translation helpful? Give feedback.
All reactions