@web-atoms/core
Version:
42 lines (41 loc) • 1.25 kB
JavaScript
System.register(["../core/AtomBinder", "../services/NavigationService"], function (_export, _context) {
"use strict";
var AtomBinder, NavigationService, NotifyType;
function bindPromise(vm, p, value, displayError = true) {
p.then(v => {
if (Array.isArray(v)) {
const a = value;
a.replace(v);
} else {
for (const key in v) {
if (v.hasOwnProperty(key)) {
const element = v[key];
value[key] = element;
AtomBinder.refreshValue(value, key);
}
}
}
}).catch(e => {
if (displayError) {
if (typeof displayError === "function") {
displayError(e);
} else {
const n = vm.app.resolve(NavigationService);
n.notify(e, "Error", NotifyType.Error);
}
}
});
return value;
}
_export("default", bindPromise);
return {
setters: [function (_coreAtomBinder) {
AtomBinder = _coreAtomBinder.AtomBinder;
}, function (_servicesNavigationService) {
NavigationService = _servicesNavigationService.NavigationService;
NotifyType = _servicesNavigationService.NotifyType;
}],
execute: function () {}
};
});
//# sourceMappingURL=bindPromise.js.map