how to replace a service with a Subject with signals?

Discussão em 'Angular' iniciado por dalox, Dezembro 3, 2024.

  1. dalox

    dalox Guest

    Say I have a very simple shared service holding a subject:

    @Injectable({ providedIn: 'root' })
    export class MyService {
    private _runTaskSubject = new Subject<string>();

    get runTaskSubject$() {
    return this._runTaskSubject.asObservable();
    }

    runTask(name: string) {
    this._runTaskSubject.next(string);
    }
    }


    Observers of that runTaskSubject$ will only get notified once runTask is called.

    Now I was thinking to convert this service using signals, but it seems that not an option as signals always hold an initial value. So does it makes sense to keep my rxjs Subject for this use case?

    Continue reading...

Compartilhe esta Página