core-native
Version:
A lightweight framework based on React Native + Redux + Redux Saga, in strict TypeScript.
20 lines • 611 B
JavaScript
import { call as sagaCall } from "redux-saga/effects";
export const call = (fn, ...args) => {
let result;
// Same as fn (parameter), but store its promised return into "result"
const wrappedFn = (...args) => {
return fn(...args).then(_ => {
result = _;
return _;
});
};
const effect = sagaCall.apply(null, [wrappedFn, ...args]);
effect.result = () => {
if (result === undefined) {
throw new Error("Effect has not been yielded");
}
return result;
};
return effect;
};
//# sourceMappingURL=sagaCall.js.map