Should do async stop but did sync stop [edited title] #185
Open
Description
This 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)
}
})