Skip to content

Commit

Permalink
Always emit a change
Browse files Browse the repository at this point in the history
  • Loading branch information
goatslacker committed Mar 14, 2015
1 parent 43731ce commit 44ad1de
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 14 deletions.
2 changes: 2 additions & 0 deletions dist/alt-browser-with-addons.js
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,7 @@ var Alt = (function () {
if (store[LIFECYCLE].rollback) {
store[LIFECYCLE].rollback();
}
store.emitChange();
});
}
},
Expand Down Expand Up @@ -1483,6 +1484,7 @@ var Alt = (function () {
if (store[LIFECYCLE].bootstrap) {
store[LIFECYCLE].bootstrap();
}
store.emitChange();
});
}
},
Expand Down
2 changes: 2 additions & 0 deletions dist/alt-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,7 @@ var Alt = (function () {
if (store[LIFECYCLE].rollback) {
store[LIFECYCLE].rollback();
}
store.emitChange();
});
}
},
Expand Down Expand Up @@ -1227,6 +1228,7 @@ var Alt = (function () {
if (store[LIFECYCLE].bootstrap) {
store[LIFECYCLE].bootstrap();
}
store.emitChange();
});
}
},
Expand Down
2 changes: 2 additions & 0 deletions dist/alt-with-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ var Alt = (function () {
if (store[LIFECYCLE].rollback) {
store[LIFECYCLE].rollback();
}
store.emitChange();
});
},
writable: true,
Expand Down Expand Up @@ -509,6 +510,7 @@ var Alt = (function () {
if (store[LIFECYCLE].bootstrap) {
store[LIFECYCLE].bootstrap();
}
store.emitChange();
});
},
writable: true,
Expand Down
2 changes: 2 additions & 0 deletions dist/alt.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ var Alt = (function () {
if (store[LIFECYCLE].rollback) {
store[LIFECYCLE].rollback();
}
store.emitChange();
});
},
writable: true,
Expand Down Expand Up @@ -526,6 +527,7 @@ var Alt = (function () {
if (store[LIFECYCLE].bootstrap) {
store[LIFECYCLE].bootstrap();
}
store.emitChange();
});
},
writable: true,
Expand Down
14 changes: 1 addition & 13 deletions docs/bootstrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,7 @@ permalink: /docs/bootstrap/

> (data: string): undefined
The `alt.bootstrap()` function takes in a snapshot you've saved and reloads all the state with that snapshot, no events will be emitted to your components during this process, so it is advised to do this on init before the view has even rendered.

If you want to emit a change event after bootstrapping you can use [`this.emitChange`](stores.md#storeemitchange) inside of the [bootstrap lifecycle method](lifecycleListeners.md#bootstrap).

```js
class MyStore {
constructor() {
this.on('bootstrap', () =>
this.emitChange();
});
}
}
```
The `alt.bootstrap()` function takes in a snapshot you've saved and reloads every store's state with that the data provided in that snapshot.

Bootstrap is great if you're running an isomorphic app, or if you're persisting state to localstorage and then retrieving it on init later on. You can save a snapshot on the server side, send it down, and then bootstrap it back on the client.

Expand Down
2 changes: 2 additions & 0 deletions src/alt.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ class Alt {
if (store[LIFECYCLE].rollback) {
store[LIFECYCLE].rollback()
}
store.emitChange()
})
}

Expand Down Expand Up @@ -421,6 +422,7 @@ class Alt {
if (store[LIFECYCLE].bootstrap) {
store[LIFECYCLE].bootstrap()
}
store.emitChange()
})
}

Expand Down
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class MyStore {
}

externalMethodNoStatic() {
return true
return true
}
}

Expand Down

0 comments on commit 44ad1de

Please sign in to comment.