Can’t import the Observable package from the timer feature?

Asked

Viewed 62 times

0

Watch this tutorial carefully:

Importing RXJS Observable functions in Angular 5

I’m having difficulty performing the Observable Resource Import timer, I’ve tried to write the path in several ways and I can’t care.

Look at the headline of my class!

inserir a descrição da imagem aqui

I tried to install other versions of rxjs

I had the "rxjs": "5.1.0", but then I tried the version "rxjs": "^5.5.5" and the version "rxjs": "^6.2.2", and unsuccessfully.

I really need help

  • 1

    In version 6+ it would be import { timer } from 'rxjs';

  • I’m sorry, I didn’t understand what you said.

  • 1

    In the version of rxjs 6 or higher it would look like this: import { timer } from 'rxjs';

  • @Eduardovargas sorry, but your suggestion did not take.

  • 1

    Delete Node modules and install everything dnv. Make sure you are using 6. It may be that your project is not configured correctly tbm. You used the angular cli to generate it?

  • 1

    Your other Imports tbm are weird it was supposed to be @angular/animations and not have node_modules for example. You are using an absolute rather than relative pathing.

  • I just solved, installed the version "rxjs": "5.1.0" and set that path import { Observable } from '../../../../node_modules/rxjs/rx'; and it worked.

  • 1

    Strange to have node_modules in your Imports...

  • Very strange. Ever thought of using only import { Observable } from 'rxjs/rx; ? Doesn’t spoil anything?

Show 4 more comments

1 answer

2


import 'rxjs/add/observable/timer';

const timer = Observable.timer(1, 1000);
    this.sub = timer.subscribe(
      t => console.log(`passou 1 segundo));

Browser other questions tagged

You are not signed in. Login or sign up in order to post.