aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/odlux/framework/src/middleware/thunk.ts
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/odlux/framework/src/middleware/thunk.ts')
-rw-r--r--sdnr/wt/odlux/framework/src/middleware/thunk.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/sdnr/wt/odlux/framework/src/middleware/thunk.ts b/sdnr/wt/odlux/framework/src/middleware/thunk.ts
new file mode 100644
index 000000000..3844485ec
--- /dev/null
+++ b/sdnr/wt/odlux/framework/src/middleware/thunk.ts
@@ -0,0 +1,18 @@
+
+import { Dispatch } from '../flux/store';
+import { MiddlewareApi } from '../store/applicationStore';
+
+function createThunkMiddleware() {
+ return ({ dispatch, getState }: MiddlewareApi) =>
+ (next : Dispatch) : Dispatch =>
+ action => {
+ if (typeof action === 'function') {
+ return action(dispatch, getState);
+ }
+
+ return next(action);
+ };
+}
+
+export const thunk = createThunkMiddleware();
+export default thunk; \ No newline at end of file