startWith does not exist on type Subject<unknow>

129 views
Skip to first unread message

Paulo Silva

unread,
Jul 29, 2020, 11:25:10 AM7/29/20
to Angular and AngularJS discussion
I got this code below
resetTimer$ = new Subject();

  ngOnInit() {
    this.resetTimer$
      startWith(null)
      .takeUntil(this.destroyed$)
      .switchMap(t => Observable.timer(50005000))
      .subscribe(() => this.next())
  }

I'm using  Angular 10 and i'm getting this error:
startWith does not exist on type Subject<unknow>

How can i solve this problem? 

bastien lemaire

unread,
Jul 29, 2020, 11:50:53 AM7/29/20
to ang...@googlegroups.com
this.resetTimer$.pipe(
  startWith(),
  takeUntil(),
  ...
)

Bastien Lemaire


--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angular/109c97a1-9538-456b-9839-045e6240f2f9o%40googlegroups.com.

Paulo Silva

unread,
Jul 29, 2020, 12:15:04 PM7/29/20
to Angular and AngularJS discussion
I made this way but remain the same error like this

bastien lemaire

unread,
Jul 29, 2020, 12:21:33 PM7/29/20
to ang...@googlegroups.com
Ok you need to import the functions:

import {startWith, takeUntil, switchMap} from 'rxjs/operators';

class Component {
  public ngOnInit(): void {
    this.resetTimers$.pipe(
      startWith(10),
      switchMap(),
      takeUntil()
    )
    .subscribe()
    ;
  }
}

I typed this up quickly there could be some typos.

NOTE subscribe goes after the closing bracket of the pipe() function

Bastien Lemaire


--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.

Paulo Silva

unread,
Jul 29, 2020, 1:47:53 PM7/29/20
to Angular and AngularJS discussion
Ok, @Bastien Lemaire, your approach worked! Thank you
 I'm getting started with Angular. 

Em quarta-feira, 29 de julho de 2020 12:25:10 UTC-3, Paulo Silva escreveu:

Paulo Silva

unread,
Jul 29, 2020, 2:16:44 PM7/29/20
to Angular and AngularJS discussion
Hi, i wrote that is worked, but not. The line 
switchMap(t => Observable.timer(50005000)))
says Property timer does not exist on type ' typeof Observable


Em quarta-feira, 29 de julho de 2020 12:25:10 UTC-3, Paulo Silva escreveu:

Paulo Silva

unread,
Jul 29, 2020, 2:38:29 PM7/29/20
to Angular and AngularJS discussion
I imported timer as wich import { Observable, timer } from rxjs and i removed Observable from t => Observable.timer  and now i will run


Em quarta-feira, 29 de julho de 2020 12:25:10 UTC-3, Paulo Silva escreveu:

Paulo Silva

unread,
Jul 29, 2020, 2:40:47 PM7/29/20
to Angular and AngularJS discussion
Not worked


Em quarta-feira, 29 de julho de 2020 12:25:10 UTC-3, Paulo Silva escreveu:

Scott Logsdon

unread,
Jul 29, 2020, 3:06:42 PM7/29/20
to ang...@googlegroups.com
You don't have to use RXJS.  



Best Regards,

 

Scott Logsdon, Web Developer
Ser.vi Worldwide LLC USA & Ser.vi BV Europe
Email: sc...@ser.vi

 



--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages