1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

ngrx SignalStore: Calling a service function without parameters, which returns an Observable

Discussão em 'Angular' iniciado por Jargo, Setembro 18, 2025.

  1. Jargo

    Jargo Guest

    I have an Angular Service which lets me load data using HttpClient.request(...) and returns the data as an Observable. Within my ngrx SignalStore I call these service methods within rxMethod()s.

    One of my service methods does not have any parameters. So calling it within an rxMethod() is not an option, because rxMethod() requires a parameter, be it


    a static value, signal, or observable as an input argument
    ​

    So this won't work, because I do not have a parameter to call load() with:

    withMethods((
    store,
    service = inject(SomeService),
    ) => ({
    load: rxMethod(pipe(
    switchMap(() => service.getAll$()
    .pipe(
    tap(models => {
    store.initWithEntities(models);
    }),
    ),
    ),
    )),
    }),
    ),


    What is the best practice in this case? I'd rather not use a normal SignalStore method, because I'd like to not have to bother with subscription management.

    Continue reading...

Compartilhe esta Página