17 lines
444 B
JavaScript
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);
|
|
}
|
|
};
|
|
};
|