Skip to content

Commit

Permalink
refactor(app/stateObserver): rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
exuanbo committed Dec 8, 2023
1 parent 6f0ab42 commit 932f64a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/app/stateObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ export const createStateObserver = <TState>(): StateObserver<TState> => {

const middleware: Middleware = (api) => {
state$.next(api.getState())
let nestedDepth = 0
let dispatchDepth = 0

return (next) => (action) => {
try {
nestedDepth += 1
dispatchDepth += 1
const result = next(action)
if (nestedDepth === 1) {
if (dispatchDepth === 1) {
state$.next(api.getState())
}
return result
} finally {
nestedDepth -= 1
dispatchDepth -= 1
}
}
}
Expand Down

0 comments on commit 932f64a

Please sign in to comment.