redux-saga-final-form
Advanced tools
Comparing version 2.1.0-2 to 2.1.0-3
@@ -8,3 +8,2 @@ "use strict"; | ||
const dispatch = react_redux_1.useDispatch(); | ||
const store = react_redux_1.useStore(); | ||
return (payload) => { | ||
@@ -15,6 +14,6 @@ const action = { | ||
}; | ||
if (!storeMap.has(store)) { | ||
storeMap.set(store, new Map()); | ||
if (!storeMap.has(dispatch)) { | ||
storeMap.set(dispatch, new Map()); | ||
} | ||
const pendingCallbacks = storeMap.get(store); | ||
const pendingCallbacks = storeMap.get(dispatch); | ||
return new Promise((resolve, reject) => { | ||
@@ -42,3 +41,3 @@ if (!pendingCallbacks.has(resolveActionType)) { | ||
return next => action => { | ||
const pendingCallbacks = storeMap.get(store); | ||
const pendingCallbacks = storeMap.get(store.dispatch); | ||
if (pendingCallbacks) { | ||
@@ -45,0 +44,0 @@ const cbInfos = pendingCallbacks.get(action.type); |
{ | ||
"name": "redux-saga-final-form", | ||
"version": "2.1.0-2", | ||
"version": "2.1.0-3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
import { useDispatch, useStore } from 'react-redux'; | ||
import { Middleware, Store } from 'redux' | ||
import { Middleware, Dispatch } from 'redux' | ||
@@ -9,7 +9,6 @@ interface CbInfo { | ||
const storeMap = new WeakMap<Store, Map<string, CbInfo[]>>(); | ||
const storeMap = new WeakMap<Dispatch, Map<string, CbInfo[]>>(); | ||
export function useListener(startActionType: string, resolveActionType: string, rejectActionType: string, setPayload?: (payload: any) => Object) { | ||
const dispatch = useDispatch(); | ||
const store = useStore(); | ||
return (payload: any) => { | ||
@@ -20,6 +19,6 @@ const action = { | ||
}; | ||
if (!storeMap.has(store)) { | ||
storeMap.set(store, new Map()) | ||
if (!storeMap.has(dispatch)) { | ||
storeMap.set(dispatch, new Map()) | ||
} | ||
const pendingCallbacks = storeMap.get(store)!; | ||
const pendingCallbacks = storeMap.get(dispatch)!; | ||
@@ -49,3 +48,3 @@ return new Promise((resolve, reject) => { | ||
return next => action => { | ||
const pendingCallbacks = storeMap.get(store as any)!; | ||
const pendingCallbacks = storeMap.get(store.dispatch)!; | ||
if (pendingCallbacks) { | ||
@@ -52,0 +51,0 @@ const cbInfos = pendingCallbacks.get(action.type)!; |
12361
170