2

I am new to react and wondering what the best way to have decoupled communication in a modular React based application. Actually my issue is a plain old JavaScript abstraction over a restful API that is consumed by a React application.

I have a need to notify a consumer of the API abstraction that something has happened (session has timed out on the server as it happens).

Ordinarily I would use pub sub / an event bus.

I have considered adding another shared redux layer but that still couples everything together though delegates the coupling into the shared module which I guess is a mediator.

I can't find much about this online.

Anyone got thoughts on this?

Thanks

airwalker
  • 53
  • 2
  • 7
  • Well redux is the way to go here. You can just dispatch actions if an error happens, which will alter the state and react can pick up the updated state. Its pretty similar to event... – Scarysize Jul 07 '16 at 19:38
  • 1
    I know it's late, but I just created this lib, check it https://www.npmjs.com/package/redux-bus – challenger Mar 01 '17 at 15:43

1 Answers1

0

You could use Redux Saga/ Thunk for the above purpose

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 23 '21 at 07:25