Skip to content

Commit

Permalink
feat(migration): use default state value for master key otherwise get…
Browse files Browse the repository at this point in the history
… value for key
  • Loading branch information
marcjulian committed Dec 12, 2019
1 parent a968969 commit 7d4bff3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lib/async-storage.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ export class NgxsAsyncStoragePlugin implements NgxsPlugin {
}
} else {
if (options.migrations) {
val = Object.assign({}, state);
if (isMaster) {
val = state;
} else {
val = getValue(state, key);
}
options.migrations.forEach(strategy => {
const versionMatch =
strategy.version ===
Expand All @@ -102,7 +106,6 @@ export class NgxsAsyncStoragePlugin implements NgxsPlugin {
hasMigration = true;
}
});

if (!isMaster) {
nextState = setValue(previousState, key, val);
} else {
Expand Down

0 comments on commit 7d4bff3

Please sign in to comment.