Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

append does not dispose the second signal #274

Open
ioninks opened this issue Jul 13, 2021 · 0 comments
Open

append does not dispose the second signal #274

ioninks opened this issue Jul 13, 2021 · 0 comments

Comments

@ioninks
Copy link

ioninks commented Jul 13, 2021

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant