UNPKG

core-native

Version:

A lightweight framework based on React Native + Redux + Redux Saga, in strict TypeScript.

29 lines 870 B
import { createActionHandlerDecorator } from "./index"; /** * If specified, the action cannot be entered by other sagas during execution. * For error handler action, mutex logic is auto added. */ export function Mutex() { let lockTime = null; return createActionHandlerDecorator(function* (handler, thisModule) { if (lockTime) { thisModule.logger.info({ action: handler.actionName, info: { payload: handler.maskedParams, mutex_locked_duration: (Date.now() - lockTime).toString(), }, }); } else { try { lockTime = Date.now(); yield* handler(); } finally { lockTime = null; } } }); } //# sourceMappingURL=Mutex.js.map