[discussion] clean imports to replace `rxjs/add/observable/xyz`
See original GitHub issueNow that lettable operators are coming (#2667) to get rid of the import 'rxjs/add/operator/xyz'
mess, the static Observable methods for creation (of
, timer
, …) and composition (merge
, zip
, …) will probably need the same treatment to get rid of import 'rxjs/add/observable/xyz'
.
I didn’t find any issue or PR for this (probably not in scope of #2667, judging by the title and current commits), but I’m sure @benlesh has some ideas already?
It already seems to be possible to import these static methods properly using import { merge } from 'rxjs/observable/merge'
etc, although this is not documented in the installation section of the docs.
However, if I didn’t miss anything this approach seems quite clunky because
- each method requires a separate import statement
- the imports are not available on one central object like they are on
Observable
when using theadd/observable
imports - resulting from 2, they may need to be aliased because e.g.
merge
is a very generic name that does not convey correlation with RxJS
My personal comments on this:
1 could be resolved by centralizing the exports of the static methods similar to the rxjs/operators
from #2667
2 does not appear to have an obvious solution, unfortunately there is no import { merge, zip } as ObservableFactoryThingy
unless you’re importing everything (*
)
3 is probably not a large problem, especially since the same thing will apply for lettable operators (map
, min
etc). I certainly don’t think it justifies exporting them as observableOf
, mergeObservables
etc instead. Either way, a possible solution to 2 might resolve 3 as well.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:10 (2 by maintainers)
FWIW: There has always been the ability to import these directly via:
The only noteworthy exceptions are
throw
andif
, which are exported with underscores because of keyword collisions: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.