performance improvement

This commit is contained in:
Guillermo Rauch 2016-07-13 17:21:23 -07:00
parent 5e3e2c6a7d
commit 4a59c13c77
2 changed files with 9 additions and 8 deletions

View file

@ -21,6 +21,6 @@
<div id="mount"></div>
<script>start = performance.now();</script>
<script src="dist/bundle.js"></script>
<script>console.log('bundle init:', performance.now() - start);</script>
<script>console.log('total init time', performance.now() - start);</script>
</body>
</html>

View file

@ -22,15 +22,16 @@ import {
export function addSession (uid) {
return (dispatch, getState) => {
const { sessions } = getState();
// normally this would be encoded as an effect
// but the `SESSION_ADD` action is pretty expensive
// and we want to get this out as soon as possible
const initial = null == sessions.activeUid;
return dispatch({
if (initial) rpc.emit('init');
dispatch({
type: SESSION_ADD,
uid,
effect () {
if (initial) {
rpc.emit('init');
}
}
uid
});
};
}