I was using JS 3.x to add and update data. I am working on convert my applications to JS 4.x. I had a script that used "dojo/Deferred". Here is the code:
function _applyAdds (featureLayer, propertiesArr)
{
var defer;
require (['esri/graphic', "dojo/Deferred"], function (Graphic, Deferred)
{
defer = new Deferred ();
var graphicsArr = [];
propertiesArr.forEach (function (properties)
{
graphicsArr.push (new Graphic (null, null, properties));
});
featureLayer.applyEdits (
graphicsArr, null, null,
function (a, u, d)
{
console.log (a, u, d);
defer.resolve ();
}, // callback
function (error)
{
console.log ('ERROR!', error);
}// errorback
);
});
return defer.promise;
}
//begin adding new employee assignment
function assignEmployee ()
{
var addEmployee = {};
addEmployee.SPACEKEY = document.getElementById ('EmployeeSpaceID').value;
addEmployee.EMPLOYEEKEY = document.getElementById ('EmployeeID').value;
console.log (addEmployee);
_applyAdds (roomAssinmentTable, [addEmployee]).then (function ()
{
console.log ("Add Employee");
});
}
How do i make this work in JS 4.x?
Thank you in advance for any help on this.