Make document titles work
This commit is contained in:
@ -47,6 +47,12 @@ app$({ history, location: appLocation })
|
|||||||
location => location && location.key ? location.key : location
|
location => location && location.key ? location.key : location
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// set page title
|
||||||
|
appStore$
|
||||||
|
.pluck('title')
|
||||||
|
.doOnNext(title => document.title = title)
|
||||||
|
.subscribe(() => {});
|
||||||
|
|
||||||
synchroniseHistory(
|
synchroniseHistory(
|
||||||
history,
|
history,
|
||||||
updateLocation,
|
updateLocation,
|
||||||
@ -55,8 +61,11 @@ app$({ history, location: appLocation })
|
|||||||
routerState$
|
routerState$
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
// allow store subscribe to subscribe to actions
|
||||||
|
.delay(10)
|
||||||
.flatMap(({ props, appCat }) => {
|
.flatMap(({ props, appCat }) => {
|
||||||
props.history = history;
|
props.history = history;
|
||||||
|
|
||||||
return render$(
|
return render$(
|
||||||
appCat,
|
appCat,
|
||||||
React.createElement(Router, props),
|
React.createElement(Router, props),
|
||||||
|
@ -25,22 +25,6 @@ export default contain(
|
|||||||
username: PropTypes.string
|
username: PropTypes.string
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
const title = this.props.title;
|
|
||||||
this.setTitle(title);
|
|
||||||
},
|
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
|
||||||
if (nextProps.title !== this.props.title) {
|
|
||||||
this.setTitle(nextProps.title);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
setTitle(title) {
|
|
||||||
const doc = typeof document !== 'undefined' ? document : {};
|
|
||||||
doc.title = title;
|
|
||||||
},
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { username, points, picture } = this.props;
|
const { username, points, picture } = this.props;
|
||||||
const navProps = { username, points, picture };
|
const navProps = { username, points, picture };
|
||||||
|
@ -54,6 +54,12 @@ export default function reactSubRouter(app) {
|
|||||||
.flatMap(function({ props, AppCat }) {
|
.flatMap(function({ props, AppCat }) {
|
||||||
const cat = AppCat(null, services);
|
const cat = AppCat(null, services);
|
||||||
debug('render react markup and pre-fetch data');
|
debug('render react markup and pre-fetch data');
|
||||||
|
const store = cat.getStore('appStore');
|
||||||
|
|
||||||
|
// primes store to observe action changes
|
||||||
|
// cleaned up by cat.dispose further down
|
||||||
|
store.subscribe(() => {});
|
||||||
|
|
||||||
return renderToString$(
|
return renderToString$(
|
||||||
cat,
|
cat,
|
||||||
React.createElement(RoutingContext, props)
|
React.createElement(RoutingContext, props)
|
||||||
|
Reference in New Issue
Block a user