Skip to content

Commit

Permalink
add missing store method getPatches
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu-satija committed Sep 11, 2020
1 parent a6dbf9c commit c017b2f
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions example/index.tsx
Original file line number Diff line number Diff line change
@@ -62,6 +62,8 @@ const [test, setTest] = store.useDoc('/test');
setTest('kkkkkk');
// undoable(() => true);

console.log(store.getPatches('doc'));

const disposeObs = store.observe(
'doc',
'/todos',
9 changes: 9 additions & 0 deletions src/DocStore.ts
Original file line number Diff line number Diff line change
@@ -139,6 +139,15 @@ by passing name in plugin configuration to createPlugin.
}
return get(state, jsonPatchPathToImmerPath(path).join('.'));
};
getPatches = (subtree: string) => {
const subtreeState = this.reduxStore.getState()[subtree];
if (!subtreeState) {
console.warn(`Tried to access non-existent subtree ${subtree}`);
return undefined;
}

return subtreeState.patches;
};
observe = (
subtree: string,
path: string = '',

0 comments on commit c017b2f

Please sign in to comment.