I am currently building an events service, and here is the code snippet I am using:
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
export interface IPosition {
x:number
y:number
}
export interface IPositionEvent {
id: string
position: IPosition
}
@Injectable()
export class ModelEventsService {
position$:Subject<IPositionEvent>;
constructor() {
this.position$ = new Subject().debounce(500);
}
}
However, TypeScript is throwing an error that says:
ERROR in /src/model-events.service.ts (20,49): Argument of type '500' is not assignable to parameter of type '(value: {}) => SubscribableOrPromise'.)
I have searched online for solutions, but most of them seem to be related to HTTP requests. I'm struggling to pinpoint exactly what the issue is.
It seems like I need to cast something, but I haven't been able to find the correct syntax to do so.
If I remove the .debounce(500)
, the service works fine and emits the events as expected.
Any thoughts, ideas, or help would be greatly appreciated!