M
M
MadMax902020-04-24 17:36:41
Angular
MadMax90, 2020-04-24 17:36:41

Is it possible to pass callbacks in action payload and call them in effects, reducers?

He will work. But is it correct from an architectural point of view?
Action documentation says Actions are payloads of information that send data from your application to your store. They are the only source of information for the store.

export class TestComponent{
  constructor(private service: SomeService, store: Store) {

    const callbackFn = (value) => {
      this.someFunction(value);
    }

    this.store.dispatch(someAction({
      callback: callbackFn
    }))
  }

  someFunction(value) {
    this.service.showModal(value);
  }

}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question