Files
freeCodeCamp/client/sagas/title-saga.js

18 lines
470 B
JavaScript
Raw Normal View History

2016-01-27 11:34:44 -08:00
// (doc: Object) =>
// () =>
// (next: (action: Action) => Object) =>
// titleSage(action: Action) => Object|Void
2016-02-04 15:44:02 -08:00
export default ({ doc }) => ({ getState }) => next => {
2016-01-27 11:34:44 -08:00
return function titleSage(action) {
// get next state
const result = next(action);
2016-02-04 15:44:02 -08:00
if (action.type !== 'app.updateTitle') {
2016-01-27 11:34:44 -08:00
return result;
}
2016-02-04 15:44:02 -08:00
const state = getState();
const newTitle = state.app.title;
2016-01-27 11:34:44 -08:00
doc.title = newTitle;
return result;
};
};