Files
redux-doctitle/src/middleware.js
2018-01-18 17:53:52 +01:00

17 lines
444 B
JavaScript

import {TITLE_ACTIONS_SET} from "./defs";
export const documentTitleMiddlewareFactory = (defaultTitleParts = []) => {
return (store, getState) => next => action => {
if (action.type == TITLE_ACTIONS_SET) {
let titleParts = [].concat(defaultTitleParts);
if (action.title) {
titleParts.unshift(action.title);
}
window.document.title = titleParts.join(" | ");
} else {
next(action);
}
};
};