a-chart
Version:
A-Chart is a ReactJS Library/Package to address all posibilities of Reporting Functionality
42 lines (35 loc) • 1.23 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
var RenderList = exports.RenderList = function RenderList(data, config) {
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "RENDER";
// return { type: "RENDER", items: data };
return function (dispatch) {
setTimeout(function () {
dispatch({ type: type, items: data, config: config });
}, 0);
};
};
var RenderListAPI = exports.RenderListAPI = function RenderListAPI(source, config) {
return function (dispatch) {
fetch(source).then(function (res) {
return res.json();
}).then(function (result) {
dispatch({
type: "RENDERAPI",
items: result,
config: config
});
// dispatch( returnUserdata(
// result.data
// ))
},
// Note: it's important to handle errors here
// instead of a catch() block so that we don't swallow
// exceptions from actual bugs in components.
function (error) {
alert("Data not able to load from " + source + ", " + error.message);
});
};
};
;