I have a method that returns an Observable:
clockOut(): Observable<boolean> {
let isClockedOut = new Subject<boolean>();
isClockedOut.next(false);
// Some code to clock out and return x
if (x === true) {
isClockedOut.next(true);
}
return isClockedOut.asObservable();
}
And I'm calling/subscribing to the clockOut() method like so:
ngOnInit() {
this.clockOut().subscribe((didClockOut: boolean) => {
if (didClockOut === true) {
// Do stuff
}
});
}
The clockOut() method gets called, and the code inside clockOut() executes properly, but the code block after .subscribe is not being called. Almost like clockOut() isn't returning the Observable?
I'm new to Angular and I've not worked with Observables/Subjects much. Any help is appreciated. Thanks!