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

perf(SafeSubscriber): avoid using Object.create #5646

Merged
merged 2 commits into from
Aug 25, 2020

Commits on Aug 24, 2020

  1. perf(SafeSubscriber): avoid using Object.create

    In profiling sessions, the `SafeSubscriber` constructor was showing as hot
    function for code that creates and tear downs Observables very frequently.
    The usage of `Object.create` attributes to the slowness; avoiding using it
    completely removes any overhead of `SafeSubscriber`.
    
    The `Object.create` result was used to call anonymous subscribers in their
    own context, i.e. the `this` pointer in `next`/`error`/`complete` is the
    anonymous object itself. This commit implements an alternative to achieve
    the same effect; binding the subscriber functions to the observer object.
    JoostK authored and benlesh committed Aug 24, 2020
    Configuration menu
    Copy the full SHA
    739aad6 View commit details
    Browse the repository at this point in the history
  2. feat(useDeprecatedNextContext): Puts deprecated next context behavior…

    … behind a flag
    
    - Adds a flag to `import { config } from 'rxjs';` that allows users to use the undocumented feature that gives access to `unsubscribe` via the `this` context of a `next` handler passed as part of an observer object to `subscribe`. This behavior is deprecated because it has very bad performance implications on all subscriptions and is relatively unused, definitely undocumented, and certainly mostly unknown.
    - Adds a flag to silence console warn messages that are emitted when "bad" configuration settings are used.
    - Adds some documentation.
    - Adds tests.
    
    BREAKING CHANGE: `unsubscribe` no longer available via the `this` context of observer functions. To reenable, set `config.useDeprecatedNextContext = true` on the rxjs `config` found at `import { config } from 'rxjs';`. Note that enabling this will result in a performance penalty for all consumer subscriptions.
    benlesh committed Aug 24, 2020
    Configuration menu
    Copy the full SHA
    2acf96b View commit details
    Browse the repository at this point in the history