Skip to content

refactor: avoid polluting the user's rxjs setup #2652

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

Closed
wants to merge 3 commits into from

Conversation

crisbeto
Copy link
Member

Currently, the internal uses of RxJS operators are done via patch imports, which add methods directly to the global Observable object. This can be an issue since the user may not know where these methods are coming from and may depend on them. Afterwards, if Material removes a method import, the user's app will break since the methods won't be defined anymore. This PR:

  • Replaces all of the patch imports with imports of individual operators and fixes any issues that showed up afterwards.
  • Adds a FunctionChain class to help with chaining the individually-imported operators.

Fixes #2622.

@crisbeto crisbeto requested a review from jelbourn January 14, 2017 15:22
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jan 14, 2017
someObservable.map(...).subscribe(...);

// YES
import {map} from 'rxks/operator/map';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo on rxks

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed it.

Currently, the internal uses of RxJS operators are done via patch imports, which add methods directly to the global `Observable` object. This can be an issue since the user may not know where these methods are coming from and may depend on them. Afterwards, if Material removes a method import, the user's app will break since the methods won't be defined anymore. This PR:

* Replaces all of the patch imports with imports of individual operators and fixes any issues that showed up afterwards.
* Adds a `FunctionChain` class to help with chaining the individually-imported operators.

Fixes angular#2622.
@crisbeto crisbeto force-pushed the observable-clusterfuck branch from 5af94df to 21ee585 Compare January 31, 2017 21:20
# Conflicts:
#	src/lib/autocomplete/autocomplete-trigger.ts
#	src/lib/dialog/dialog-container.ts
@jelbourn
Copy link
Member

jelbourn commented Mar 9, 2017

This is still something we need to do, but it's going to get stuck rebasing all the time if we're not ready for it. @crisbeto let's give this another try after beta.3 and ng-conf

We should also introduce a lint check at the same time so that we don't keep adding more in the future.

@jelbourn jelbourn added the blocked This issue is blocked by some external factor, such as a prerequisite PR label Apr 14, 2017
@willshowell
Copy link
Contributor

Is this still scheduled for beta 4, or do you expect it will be bumped?

@jelbourn
Copy link
Member

We may push it out a bit- we're waiting to see if rxjs will add a more convenient syntax

@crisbeto
Copy link
Member Author

Closing in favor of #5314.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked This issue is blocked by some external factor, such as a prerequisite PR cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Internal usages of RxJS operators should not patch the prototype of Observable
6 participants