Skip to content

ngrx/signals call an rxMethod from an rxMethod #4576

Closed Answered by rainerhahnekamp
kopy011 asked this question in Q&A
Discussion options

You must be logged in to vote

Why don't you just put the load method into the scope of withMethods? Like:

withMethods(
    (
      store,
      orderConfirmationService = inject(OrderConfirmationService),
      spinner = inject(NgxSpinnerService),
    ) => {
      const loadOrderConfirmations = rxMethod<{ filter: Record<string, unknown> }>(
        pipe(
          // ...
        ),
      ),

      return {
        saveOrderConfirmation: rxMethod<>(pipe(
          // call loadOrderConfirmations here
        ))
      }
    },
  ),

Other than that, I'd highly recommend you to extract both functions into separate files. You don't want to have these pipes in the signalStore file.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@kopy011
Comment options

@rainerhahnekamp
Comment options

Answer selected by kopy011
@kopy011
Comment options

@rainerhahnekamp
Comment options

@kopy011
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants