mithril.js icon indicating copy to clipboard operation
mithril.js copied to clipboard

Dependent streams should end when their parent ends

Open dead-claudia opened this issue 5 years ago • 2 comments

Expected Behavior

const s = Stream()
const c = stream.map(a => a)
s.end.map(() => console.log('parent ended'))
c.end.map(() => console.log('child ended'))
stream.end(true) // logs "parent ended" and "child ended"

Current Behavior

const s = Stream()
const c = stream.map(a => a)
s.end.map(() => console.log('parent ended'))
c.end.map(() => console.log('child ended'))
stream.end(true) // logs just "parent ended"

Possible Solution

Potentially something down the vein of this comment by @pygy, but it may need altered.

Context

I created this issue to track the issue reported in #2030 (a heavily outdated PR targeting the wrong branch).

dead-claudia avatar Nov 27 '18 21:11 dead-claudia

Note that the idea here is to close dependent streams after all parent streams close. Things like .map and scan of course only have one, but things like combine would wait for all parent streams to close first before ~~terminating~~ Edit: closing their dependents.

dead-claudia avatar Nov 27 '18 21:11 dead-claudia

My 50 cents: in Rx stream is closed when it receives Completed event so basically when any of the parent streams are closed flatMap and similar operators swallow inner Completed events of course). While I'm sure they did it for their own reasons, it can be quite confusing, especially in some UI code: hunting down that closed stream can be a pain (considering the same applies for errors).

charlag avatar Dec 06 '18 20:12 charlag