Skip to content

[discussion] clean imports to replace rxjs/add/observable/xyz #2795

@jeysal

Description

@jeysal

Now 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

  1. each method requires a separate import statement
  2. the imports are not available on one central object like they are on Observable when using the add/observable imports
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions