I'm working on a react-redux application that has an api allowing devs to get information/set information about the current state of the store. Currently, the api is initialized after the store has been created and set as a global variable in the middleware:
...case INIT_API:
global.appApi = applicationApi(action.payload);
where applicationApi
is a factory function that receives the store and returns the api methods.
function applicationApi(store) {
return {
methodOne():...
This lets you make calls to the api in the browser dev console (appApi.methodOne()
).
Here is my question: I am trying to figure out how to achieve this using webpack to expose the api instead of creating a global variable. Is this possible/any tips on execution would be much appreciated.