drnaf
Version:
Dynamic React-Native Application Framework
49 lines (36 loc) • 1.21 kB
JavaScript
import { l } from "../utilities/Logs";
doIt = (props, context) => {
// prepare usage variables
const respAction = props.action.response;
// update props
props['callback'] = (responseVal) => {
// prepare usage variables
const respStatus = responseVal.status;
const respMsg = responseVal.message;
const respActMap = isArray(respAction.map_fields_to_params);
const incomingData = responseVal.data;
const incomingDataParams = {};
// useless field
delete responseVal['response'];
for (var a = 0; a < respActMap.length; a++) {
const map = respActMap[a];
const ffid = map.field_from_incoming_data;
// keep params
incomingDataParams[ffid] = incomingData[ffid];
}
// update props
respAction['params'] = incomingDataParams;
// test callback
context.createNewPage(respAction);
}
}
function objectReady(obj) {
return (obj !== null && obj !== undefined);
}
function isArray(respAction) {
if (objectReady(respAction) && (respAction.length > 0)) {
return respAction
}
return [];
}
export default { doIt }