-
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
Additional rx* prefixed exports #3508
Comments
@bisubus Couldn't agree more. This lib is already an organizational deterrent :/ |
Please use the template provided when submitting the issue. I'm not sure what version you're talking about.
The operator versions of these are being removed.
This is only a concern for TypeScript users, but I see your point, probably worth a separate issue, along with
You can all do that on your own if you which import { zip as rxZip } from 'rxjs'
// or even
import * as rx from 'rxjs/operators';
// use rx.map, rx.zip etc. My understanding is that modern tree shakers will pick this up. I'm going to close this one for now. |
@benlesh I didn't use issue template because this is proposal/feature request, not bug report. It affects current RxJS version, 6.0.0-rc.0. I can add a template if it's the only problem.
It's good to know, but the rest of the points are applicable:
|
@bisubus Do something like this: import * as ops from 'rxjs/operator' |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Currently pipeable operator and observable creation exports lack a namespace and pollute a module where they are used with very succinct names that can collide with other imports and user variables.
The suggestion is to provide additional set of prefixed exports to the package. They won't provide breaking changes, won't significantly increase package footprint (especially if tree-shaking is in use) and won't increase output size (especially if minification is in use).
There are several important concerns that could be addressed this way. They primarily apply to observable methods/factories and operators, but other exports are affected, too (
Symbol
,Observable
):Increasingly complex API. Due to collisions between reserved words and package exports, same things have been available under different names (weird
tap
->do
->tap
change).Ambiguity leads to a lack of context. In a module that is dedicated to observables, it's easy to spot that RxJS is in use and follow which variable names belong to RxJS API and which are not. In most real-life scripts, it becomes significantly harder to read and develop RxJS code without constantly checking import list or IDE hints; also results in name collisions.
Name collisions. The burden of resolving naming conflicts in imports is placed on a developer. It's easy to unintentionally mix them up or end up with inconsistent naming.
merge
,zip
, etc.)every
,find
,debounce
... plenty of them).window
,Symbol
, potentiallyObservable
)count
,pipe
,delay
, etc.)never
operator vs. TypeScriptnever
(doesn't affect anything, just confusing)Auto-imports. Export names are ambiguous, they should be picked by hand on IDE auto-import, and it's impossible for IDE to provide auto-imports automatically (for a piece of code that is pasted).
Single
rxjs
entry point. No confusing variety of imports likerxjs/operators
(a potential cause for a known issue).All of these concerns can be addressed by adding prefixes to exports:
zip
->rxZip
,catchError
->rxCatch
(canonical names can be used for operators that collide with reserved words)zip
->rxCreateZip
/rxStaticZip
/???Symbol
->RxSymbol
The text was updated successfully, but these errors were encountered: