I am making a timer which goes 5:00, 4:59...0:00.Getting many errors while using defer,
1.Property 'pipe' does not exist on type 'void' at pipe(switchMap...
2.Expected 1 arguments, but got 2. at takeWhile
3., expected in few places in ngOnInit
4.A 'this' parameter must be the first parameter at !this.duration
5.No overload matches this call. The last overload gave the following error. Argument of type '{ throw: Error; }' is not assignable to parameter of type 'OperatorFunction<unknown, unknown="">'. Object literal may only specify known properties, and 'throw' does not exist in type 'OperatorFunction<unknown, unknown="">'.
What I have tried:
time$ = timer(0, 1000).pipe(
defer(of(this.duration)).pipe(switchMap(duration => timer(0, 1000).pipe(map(n => duration - n)),
takeWhile(n => n >0),
),
ngOnInit(): void {
if (!this.duration) {
throw new Error('duration is required')
}
}
}