redux-saga-final-form
Advanced tools
Comparing version 1.2.0 to 2.0.0-0
@@ -0,2 +1,3 @@ | ||
import { Middleware } from 'redux'; | ||
export declare function useListener(startActionType: string, resolveActionType: string, rejectActionType: string, setPayload?: (payload: any) => Object): (payload: any) => Promise<unknown>; | ||
export declare function finalFormSaga(): Generator<import("redux-saga/effects").ForkEffect<never>, void, unknown>; | ||
export declare const handleListeners: Middleware; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.finalFormSaga = exports.useListener = void 0; | ||
exports.handleListeners = exports.useListener = void 0; | ||
const react_redux_1 = require("react-redux"); | ||
const effects_1 = require("redux-saga/effects"); | ||
const pendingCallbacks = new Map(); | ||
@@ -28,10 +27,10 @@ function useListener(startActionType, resolveActionType, rejectActionType, setPayload) { | ||
exports.useListener = useListener; | ||
function* handleEvent(action) { | ||
const cbInfo = pendingCallbacks.get(action.type); | ||
pendingCallbacks.delete(cbInfo.toClear); | ||
cbInfo.callback(action.payload); | ||
} | ||
function* finalFormSaga() { | ||
yield effects_1.takeEvery((action) => !!pendingCallbacks.get(action.type), handleEvent); | ||
} | ||
exports.finalFormSaga = finalFormSaga; | ||
const handleListeners = ({ getState }) => { | ||
return next => action => { | ||
const cbInfo = pendingCallbacks.get(action.type); | ||
pendingCallbacks.delete(cbInfo.toClear); | ||
cbInfo.callback(action.payload); | ||
return next(action); | ||
}; | ||
}; | ||
exports.handleListeners = handleListeners; |
{ | ||
"name": "redux-saga-final-form", | ||
"version": "1.2.0", | ||
"version": "2.0.0-0", | ||
"description": "", | ||
@@ -18,4 +18,3 @@ "main": "dist/index.js", | ||
"peerDependencies": { | ||
"react-redux": "^7.2.2", | ||
"redux-saga": "^1.1.3" | ||
"react-redux": "^7.2.2" | ||
}, | ||
@@ -25,5 +24,4 @@ "devDependencies": { | ||
"react-redux": "^7.2.2", | ||
"redux-saga": "^1.1.3", | ||
"typescript": "^4.1.3" | ||
} | ||
} |
@@ -0,0 +0,0 @@ redux-saga-final-form |
import { useDispatch } from 'react-redux'; | ||
import { takeEvery } from 'redux-saga/effects'; | ||
import { Middleware } from 'redux' | ||
@@ -27,10 +27,11 @@ const pendingCallbacks = new Map<string, { callback: Function, toClear: string}>(); | ||
function *handleEvent(action: any) { | ||
export const handleListeners: Middleware = ({ getState }) => { | ||
return next => action => { | ||
const cbInfo = pendingCallbacks.get(action.type)!; | ||
pendingCallbacks.delete(cbInfo.toClear) | ||
cbInfo.callback(action.payload); | ||
} | ||
export function* finalFormSaga() { | ||
yield takeEvery((action: any) => !!pendingCallbacks.get(action.type), handleEvent); | ||
return next(action) | ||
} | ||
} |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
3
10940
3