-
Notifications
You must be signed in to change notification settings - Fork 3k
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
observableOf
and observableFrom
instead of of
and from
#3514
Comments
I'm indifferent with this one, but if we'are going to rename |
On our project, we already rename all such imports, e.g |
The following works without any drawbacks: import * as observable from 'rxjs';
observable.of(foo) |
@alex-okrushko Importing like that will prevent tree-shaking, AFAIK. Also it requires you to prefix everything, not just the two functions in question. |
@Airblader to take the guessing out of the equation here are the results: import { Component, Input } from '@angular/core';
import * as observable from 'rxjs';
import {take} from 'rxjs/operators';
@Component({
selector: 'hello',
template: `<h1>Inteval at {{interval | async}}!</h1>`,
styles: [`h1 { font-family: Lato; }`]
})
export class HelloComponent {
interval = observable.interval(1000).pipe(take(10));
} Before I added the There are some operators, but those are using by Angular itself. Here is after I added interval to the above mentioned Component: As you can see even though I think this should resolve it. |
Certainly, thanks :-) I do have more questions about it, but that's a bit off topic here. I'll research it on my own. |
@alex-okrushko That's an interesting result. I was also under the same impression as @Airblader that doing I now see that Ben mentioned that this is possible in another issue.
I might start doing that myself now that I know it's OK. For those new to RxJS, like me, it's helpful being able to do Seems like doing As to the names |
If you decide to rename |
@r3h0. |
I am personally in favor of not removing operators (unless there is a collision), so I wouldn't want the rename. Doing |
|
Issues
of
in errorof(1, 2, 3)
meansProposal
Rename
of
andfrom
toobservableOf
andobservableFrom
.Pros
Cons
of
andfrom
meanOther thoughts
mergeMap
et al:source$.pipe(mergeMap(() => of(1, 2, 3)))
is the same assource$.pipe(mergeMap(() => [1, 2, 3]))
. The readability of this versusof
is debatable.observableFrom
is probably the more annoying of the two changes, as it would be used more often to convert a promise ahead of other operators inside of flattening operators.The text was updated successfully, but these errors were encountered: