-
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
Discuss module structure for 6.0 #2912
Comments
For me, importing syntax ergonomics is just good-to-have thing. I have already sufficient numbers of direct path import ( |
Personally, I'm partial to option 1 above, but it would require renaming static creation methods and/or operators... which isn't amazing. |
cc/ @IgorMinar @jayphelps @mattpodwysocki for thoughts. |
My preference would be to do away with the lettable forms of operators which have a static equivalent. I imagine this would be quite controversial though... (many of you probably prefer the other form) import { timer, race, map } from 'rxjs';
const items = race(
timer(100) |> map(x => x * 100),
timer(10) |> map(x => x * 10)
); import { of, concat, map } from 'rxjs';
const items = concat(
of(1, 2, 3) |> map(x => x * 100),
of(4, 5, 6) |> map(x => x * 10)
); I used to use the prototype-based forms (e.g. This would reduce the API surface and likely remove a confusion point for some. But it comes at the obvious cost of being less flexible, and perhaps more importantly deviating from some of the other Rx implementations in other languages...though not all of them have the instance variant, and RxJava/RxGroovy call it Alternatively, there could be two buckets, import { of, concat as concatStatic } from 'rxjs/observables';
import { concat, map } from 'rxjs/operators';
const items = concatStatic(
of(1, 2, 3) |> map(x => x * 100),
of(4, 5, 6) |> map(x => x * 10) |> concat(items)
); In practice I don't think this will happen often--why would someone want to use both forms of them? I'm guessing the answer is "because sometimes it feels better to use one or the other" |
Honestly, I sorta like @jayphelps' idea here. It's less to maintain, it's cleaner to read IMO also. The only one I don't like moving is |
I heartily agree with both @benlesh on the notion of "import everything from rxjs", and with @jayphelps on the notion of shrinking the API surface area (as well as the code base itself) by not having to variations of some of these things anymore. Speaking of static concat vs "startWith", now that the packaging has lessened the need to type the word |
This is done. |
Issue
Currently users need to import operators and observable creation method methods from a variety of places and it's not always consistent or ergonomic.
Questions
What is the most ergonomic?
Do we want to try to shoot for an import process like
import { map, filter, Observable, Subject, asyncScheduler } from 'rxjs'
?Do we want to keep things mostly the same for now?
How will this affect bundling?
What about node and Electron folks?
Options
rxjs
.merge
andmerge
might need to bemergeStatic
orfromMerge
andmerge
)rxjs
, import operators fromrxjs/operators
.merge
andmerge
can keep their names.operators
.rxjs
observable creation methods fromrxjs/observable
and operators fromrxjs/operators
operators
.. in all cases we should probably still provide the ability to "deep import" operators and the like, as some bundlers still stink at tree-shaking re-export modules.
The text was updated successfully, but these errors were encountered: