Skip to content

Commit

Permalink
fix running next middlewares outside of transaction zone
Browse files Browse the repository at this point in the history
  • Loading branch information
Pawel.Majewski committed May 25, 2017
1 parent 8a82888 commit ad523db
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {StateWithTransactions} from './reducer';
* This middleware is responsible for mark action with transaction id, and reject actions which are targeting not existing.
*/
export function transactionMiddleware<S>(api: MiddlewareAPI<S>): (next: Dispatch<S>) => Dispatch<S> {
let outsideZone = Zone.current;
return (next: Dispatch<S>): Dispatch<S> => {
return <A extends ActionInTransaction>(action: A): A => {
if (!action.meta || !action.meta.transactionId) {
Expand All @@ -26,7 +27,7 @@ export function transactionMiddleware<S>(api: MiddlewareAPI<S>): (next: Dispatch
}
}

return next(action);
return outsideZone.run<A>(() => next(action));
};
};
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redux-tx",
"version": "0.2.4",
"version": "0.2.5",
"license": "MIT",
"description": "Optimistic Transactions for Redux",
"keywords": [
Expand Down

0 comments on commit ad523db

Please sign in to comment.