Skip to content

dispose of producer in deinit #24

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

pteasima
Copy link

@pteasima pteasima commented Mar 8, 2016

This fixes a crash where if the ReactiveArray was initialized with a producer and the producer sends a value after the ReactiveArray has been dealloced, the app will crash on calling a method on unowned dealloced self in _signal.observe.

Easiest way to reproduce this bug is using a mirror:

let xs = ReactiveArray<String>()
;{
let ys = xs.mirror { _ in "I will crash" }
}()
xs.append("ys shall crash now!")

There may be better ways to fix this than my solution, so feel free to implement your own.
I would have liked to use .takeUntil(willDeallocSignal) instead of the disposeBag, but I dont have a willDeallocSignal for arbitrary swift classes (not NSObject)
I could tackle this by disposing of the _signal.observe to prevent other possible problems of this kind, but I felt like my change fixes this particular problem as locally as possible.

@guidomb guidomb self-assigned this Apr 8, 2016
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

Successfully merging this pull request may close these issues.

2 participants