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

feat(Subscription): add no longer returns unnecessary Subscription … #5656

Merged

Commits on Aug 19, 2020

  1. feat(Subscription): add no longer returns unnecessary Subscription …

    …reference
    
    - Updates a few locations where this feature was being used incorrectly.
    - Eliminates confusion where people were trying to "chain" `add` calls.
    
    BREAKING CHANGE: `add` no longer returns an unnecessary Subscription reference. This means that if you are calling `add` with a _function_ and not a `Subscription` (e.g. `subscription.add(() => { /* teardown */ })`), you will not be able to remove that teardown _function_ with `remove`. The fix for this is to wrap your function with a `Subscription` like so:  `const childSub = new Subscription(() => { /* teardown */ }); subscription.add(childSub);`. Then you will be able to remove it via `subscription.remove(childSub);`. Bear in mind that is it an edge case to need to manually remove a child subscription from a parent subscription. **All subscriptions that have been added to other subscriptions will remove themselves from the parent subscription(s) automatically when they are unsubscribed.**.
    benlesh committed Aug 19, 2020
    Configuration menu
    Copy the full SHA
    dd8b8a9 View commit details
    Browse the repository at this point in the history