core-native
Version:
A lightweight framework based on React Native + Redux + Redux Saga, in strict TypeScript.
41 lines • 1.69 kB
JavaScript
import { app } from "../app";
import { stringifyWithMask } from "../util/json-util";
export { Interval } from "./Interval";
export { Loading } from "./Loading";
export { Log } from "./Log";
export { Mutex } from "./Mutex";
export { RetryOnNetworkConnectionError } from "./RetryOnNetworkConnectionError";
export { SilentOnNetworkConnectionError } from "./SilentOnNetworkConnectionError";
/**
* A helper for ActionHandler functions (Saga).
*/
export function createActionHandlerDecorator(interceptor) {
return (target, propertyKey, descriptor) => {
const fn = descriptor.value;
descriptor.value = function* (...args) {
var _a;
const boundFn = fn.bind(this, ...args);
// Do not use fn.actionName, it returns undefined
// The reason is, fn is created before module register(), and the actionName had not been attached then
boundFn.actionName = descriptor.value.actionName;
boundFn.maskedParams = stringifyWithMask(((_a = app.loggerConfig) === null || _a === void 0 ? void 0 : _a.maskedKeywords) || [], "***", ...args) || "[No Parameter]";
yield* interceptor(boundFn, this);
};
return descriptor;
};
}
/**
* A helper for regular functions.
*/
export function createRegularDecorator(interceptor) {
return (target, propertyKey, descriptor) => {
const fn = descriptor.value;
descriptor.value = function (...args) {
const rootState = app.store.getState();
const logger = app.logger;
interceptor(fn.bind(this, ...args), rootState, logger);
};
return descriptor;
};
}
//# sourceMappingURL=index.js.map