Skip to content

Usage : Dispatching actions

Pratik Bhattacharya edited this page Oct 20, 2020 · 1 revision

When dispatching actions a Micro Frontend has 2 main options: either dispatch the action in its own Redux Store or Dispatch it via the Global Store. In case the action is purely a local one, then dispatching the action directly in the Redux Store is correct. However, it's recommended to use the Dispatch method of GlobalStore to dispatch the action since other stores might be listening to these actions.

There are 3 methods exposed by GlobalStore which can be used to dispatch the action:

Dispatch (recommended)

On using this method, GlobalStore will dispatch this action to both the local store as well other stores. When dispatching to other stores, a check would be made to ensure that the store has registered the action as a Global action.

let action = { type: 'ADD_TODO', payload: 'Sample data' };
this.globalStore.DispatchAction("TodoApp", action);
Clone this wiki locally