This is middleware that lets you opt in to sending actions across open browser tabs using cross-tab-channel.
Pass crossTabMiddleware
a string to identify and/or version your app.
import crossTabMiddleware from 'cross-tab-middleware';
store = createStore(
reducer,
applyMiddleware(
thunk,
createdRouterMiddleware,
promiseMiddleware(),
crossTabMiddleware('your-app-name')
)
);
To work across different domains, cross-tab-channel uses an iframe. That HTML file is entirely self contained and can be found in the cross-tab-channel repo. It has no requirements and can be hosted statically.
import crossTabMiddleware from 'cross-tab-middleware/crossDomain';
store = createStore(
reducer,
applyMiddleware(
thunk,
createdRouterMiddleware,
promiseMiddleware(),
crossTabMiddleware('//your-domain/path/to/iframe.html', 'your-app-name')
)
);
Let the middleware know you want this action to be sent to other tabs.
export function loadUser () {
return {
type: USER_LOAD,
meta: {
crossTab: true
},
payload: {
promise: userService.load()
}
};
}