Skip to content

Commit

Permalink
No observe or intercept for depth less than 0
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu-satija committed Sep 28, 2020
1 parent 7d02bdf commit 95a3105
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/interceptMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export const createInterceptMiddleware = (
}
const payloadPath: string = action.payload.patch.path;

if (interceptor.subtree !== action.payload.subtree) {
if (
interceptor.subtree !== action.payload.subtree ||
interceptor.depth < 0
) {
// Skip this interceptor if interceptor and action.payload subtrees do not match
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/observeMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const createObserveMiddleware = (observers: Map<number, Observer>) => {
observers.forEach((observer, key) => {
const payloadPath = action.payload.patch.path;

if (observer.subtree !== action.payload.subtree) {
if (observer.subtree !== action.payload.subtree || observer.depth < 0) {
// Skip this observer if observer and action.payload subtrees do not match
return;
}
Expand Down

0 comments on commit 95a3105

Please sign in to comment.