question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What is the intended way of importing lettable operators?

See original GitHub issue

RxJS version: 5.5

I’ve been using lettable operators since 5.5 was in beta, it was great. But I have a few concerns regarding the way to import them.

Are we supposed to do this:

import { map } from 'rxjs/operators';

or:

import { map } from 'rxjs/operators/map';

Either way, it works the same. But for the sake of consistency, shouldn’t there be only one way of doing this?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:27 (6 by maintainers)

github_iconTop GitHub Comments

15reactions
kylecordescommented, Nov 14, 2017

I’m really hoping we see a future version where we can import most or all of the RxJS stuff from a single place. Here is an example I have in a simple use of RxJS right now:

import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of';
import { _throw } from 'rxjs/observable/throw';
import { delayWhen } from 'rxjs/operators';
import { timer } from 'rxjs/observable/timer';

This is rather tedious, of the 5 things I want, all 5 have to come from a different module.

I’d like to write something more like:

import { Observable, of, _throw, delayWhen, timer } from 'rxjs';

Of course I could accomplish this myself with some kind of wrapper, but I would like something close to this to become idiomatic, documented official usage. A man can dream?

8reactions
benleshcommented, Nov 27, 2017

The intended way to import lettable/pipeable operators in 5.5 is:

import { map, filter, mergeMap, tap } from 'rxjs/operators';

Sorry it took so long for me to respond. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

RxJS: Understanding Lettable Operators - ncjamieson
As with the call -based approach, lettable operators are imported explicitly. They can be imported from the operators directory (note the plural) ...
Read more >
Lettable operators in RxJs - The art of simplicity
A lettable operator is basically any function that returns a function ... import { range } from 'rxjs/observable/range'; ... All method:.
Read more >
Importing only desired features from rxjs in angular 2 component
Usually one will group them inside one single file per application and import only Observable in the places where it's neded. In the...
Read more >
angular/angular - Gitter
U have static operators and prototype operators (prior to rxjs 5.5) ... I imported everything with the lettable method, so the static Observable.merge() ......
Read more >
[TypeScript] RxJS lettable operator - type inference support
WEB-29555 RxJS lettable operators in TypeScript: no method suggestions ... from 'rxjs/Observable'; import {switchMap, map} from 'rxjs/operators'; ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found