-
Notifications
You must be signed in to change notification settings - Fork 112
Open
Description
Consider the following example:
let periodic = SafeSignal<Int>(sequence: 0..., interval: 1.0)
.map(String.init)
.debug("periodic")
let initial = SafeSignal(just: "0")
initial.append(periodic)
.prefix(maxLength: 3)
.debug("final")
.observeNext { _ in }
.dispose(in: bag)
If we run it, here is what will be printed out:
[final] started
[final] next(0)
[periodic] started
[periodic] next(0)
[final] next(0)
[periodic] next(1)
[final] next(1)
[final] finished
[final] disposed
[periodic] next(2)
[periodic] next(3)
[periodic] next(4)
[periodic] next(5)
...
So as you can see the periodic
signal was not disposed and keeps producing elements.
Furthermore, if we replace append(periodic)
with merge(with: periodic)
it is disposed correctly:
[final] started
[final] next(0)
[periodic] started
[periodic] next(0)
[final] next(0)
[periodic] next(1)
[final] next(1)
[periodic] disposed
[final] finished
[final] disposed
Metadata
Metadata
Assignees
Labels
No labels