Should do async stop but did sync stop [edited title]
See original GitHub issueThis is the example of http
like cycle driver where the request is resolved synchronously. Couldn’t narrow it down simple xstream pattern, but I wonder why for one request in sink in this case it actually does two requests (starts stream two times).
import xs from 'xstream'
import delay from 'xstream/extra/delay'
let requestsCount = 0
const driverWithSyncResponse = (request$) => {
const createResponse$ = (request) => {
const stream$ = xs.create({
start: (listener) => {
requestsCount++
listener.next(request.num)
listener.complete()
},
stop: () => { }
}).remember()
stream$.addListener({ next: () => { } })
return stream$
}
const r$$ = request$.map(createResponse$)
r$$.addListener({ next: () => { } })
return r$$
}
const request$ = xs.of({ num: 1 }).compose(delay(0))
const r$$ = driverWithSyncResponse(request$)
r$$.flatten()
.addListener({
next: (res) => {
console.log('Actual requests count should be 1, but it is', requestsCount)
}
})
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Async.StartChild with timeout and sync wait inside of child async
When Async.StartChild needs to cancel the child workflow, it will request a cancellation on the token, and then it falls to the child ......
Read more >Async/Await - Best Practices in Asynchronous Programming
Asynchronous code works best if it doesn't synchronously block. Figure 5 is a cheat sheet of async replacements for synchronous operations.
Read more >Async Timeout policies do not cancel sync-blocking Thread ...
I have a handler with high latency(which has high latency than configured timeout). But the timeout(client.Timeout) or Polly timeout policies ...
Read more >Async methods do not stop executing when exiting play mode ...
I wouldn't say intended necessarily. But yes, threads you've spun up yourself don't necessarily stop when exiting play mode in the editor.
Read more >Use Promise.all to Stop Async/Await from Blocking Execution ...
Don't use await inside loops. Create an array of Promises and await Promise.all instead. This article will walk through a few examples and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah, so I think this is only about whether MemoryStream should be one-time use or be resetable. There is no correct answer. I’ve seen this exact issue in RxJS, I recommend reading the discussion: https://github.com/ReactiveX/rxjs/issues/453
Right now, I’m inclined to do what RxJS eventually did: allow reusable MemoryStream. Which means keeping the current behavior, and if you really want MemoryStream to keep the value, then appending it with xs.never().
xs.merge(s, xs.never())
is becoming a common “hack”, we might consider the idea of making it idiomatic with e.g.x$.neverEnd()
Hey @whitecolor, most (okay all) of the bins linked to this seem to have expired, but do the snippets make sense? Does the suggested pattern work for you?