Skip to content

Pipeable - #8976

Merged
hansl merged 1 commit into
angular:masterfrom
Brocco:lettable
Jan 23, 2018
Merged

hansl merged 1 commit into
angular:masterfrom
Brocco:lettable

Conversation

@Brocco

@Brocco Brocco commented Dec 22, 2017

Copy link
Copy Markdown
Contributor

No description provided.

import {LogEntry, Logger} from './logger';
import {ConsoleLoggerStack} from './console-logger-stack';
import {NullLogger} from './null-logger';
import {toArray} from 'rxjs/operators';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be an import directly from 'rxjs/operators/toArray'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

no, importing from 'rxjs/operators' is fine

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is to maintain parity with angular/material2, angular/flex-layout, and angular/preboot, starting with angular/components#8160. It seems like it's an open question though on that thread, and will probably become irrelevant as RxJS 6 comes closer

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Importing from operators does cause a larger bundle currently but from memory that's a bug at the moment and should be fixed. With that in mind I think the more ergonomic approach should be the desired kne

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please note also that this is a node application not a web application. Bundle size is irrelevant.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's more about setting a precedent for best practices, as a lot of developers look to first-party packages like this for guidance (node app or no), especially when it comes to RxJS. Again, for this at least it seems to be a non-starter, the only reason I'm leaving this comment up is to archive the discussion.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Best practices for RxJS 6 is to import {toArray} from 'rxjs'. I'm personally okay with this as it's likely the whole Angular ecosystem will move towards that over the next quarter or two.

@CDDelta

CDDelta commented Dec 26, 2017

Copy link
Copy Markdown

Maybe blacklist importing the whole rxjs library by adding this to tslint.json "import-blacklist": [true, "rxjs", "rxjs/operators"]

@trotyl

trotyl commented Dec 27, 2017

Copy link
Copy Markdown
Contributor

@CDDelta Importing from rxjs/operators won't cause any bundle size problem in runtime:

image

Let alone this change is for cli tasks only.

@CDDelta

CDDelta commented Dec 27, 2017

Copy link
Copy Markdown

@trotyl I just thought it would be a good idea since that was what @CaerusKaru was pushing for, but you are right this is more of a style thing than a tree-shaking thing.

import {Observable} from 'rxjs/Observable';

import 'rxjs/add/observable/empty';
import { EmptyObservable } from 'rxjs/Observable/EmptyObservable';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lower case 'o' in rxjs/observable/EmptyObservable.
Also rxjs v6 appears to be moving towards using creation helpers over class instantiation. So may want to go with import { empty } from 'rxjs/observable/empty';

@hansl
hansl merged commit 5a736bd into angular:master Jan 23, 2018
@Brocco
Brocco deleted the lettable branch April 3, 2018 13:13
@angular-automatic-lock-bot

Copy link
Copy Markdown

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 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants