-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
163 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,28 @@ export function registerStores(reactorState, stores) { | |
}) | ||
} | ||
|
||
/** | ||
* Overrides the store implementation without resetting the value of that particular part of the app state | ||
* this is useful when doing hot reloading of stores. | ||
* @param {ReactorState} reactorState | ||
* @param {Object<String, Store>} stores | ||
* @return {ReactorState} | ||
*/ | ||
export function replaceStores(reactorState, stores) { | ||
return reactorState.withMutations((reactorState) => { | ||
each(stores, (store, id) => { | ||
const initialState = store.getInitialState() | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jordangarcia
Author
Contributor
|
||
if (getOption(reactorState, 'throwOnNonImmutableStore') && !isImmutableValue(initialState)) { | ||
throw new Error('Store getInitialState() must return an immutable value, did you forget to call toImmutable') | ||
} | ||
|
||
reactorState | ||
.update('stores', stores => stores.set(id, store)) | ||
}) | ||
}) | ||
} | ||
|
||
/** | ||
* @param {ReactorState} reactorState | ||
* @param {String} actionType | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Should this be or?