The Sketch docs for 4.10 list 'create' 'redo' 'undo' and 'update' as the events it can fire.
(Sketch | API Reference | ArcGIS API for JavaScript 4.10 )
There's a trash-can icon that fires a 'update:cancelled' event - but that's the same event as hitting escape during an edit.
But ... in the javascript source, an undocumented 'reset' event is fired when the user deletes via the trash-icon.
Is this simply missing from the docs, or a purposefully not-ready-for-consumption API?
(I'd like to listen to this event, and not worry about regression later on...)
Solved! Go to Solution.
For the benefit of anyone finding this thread, the reply that should have been:
ESRI: "Hi Nathan, yes it is an odd pattern. We have spoken to our developers and they have said it is an omission from the documentation, but for good reason. They will be adding a 'delete' event in 4.11, which means the undocumented 'reset' event will no longer exist"
Nathan: "Thanks ESRI, great answer"
Nathan,
Reset is a documented method and not an event.
https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch.html#reset
That is true about the documentation, but I do mean events and I am asking/hoping the documentation needs fixing
There are corresponding events for all the programatic methods, with the notable exception of 'reset'.
Contrary to the docs, this code works and fixes my problem of knowing when delete has been pressed:
// Warning: This was undocumented for ESRI 4.10's API, but was found with some JS hacking
// https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch.html
this.drawingTools.on('reset', (e) => {
console.log( "%cReset", "background:cyan;", e );
this.mapGeoFilterManager.handleUpdatesFromUser();
});
I just need to know if this is safe or likely to change, and in doing so, maybe drawing attention to missing documentation.
Nathan,
It is likely to change. The API team has stated in the past that they are not going to use many events in the 4.x API since they have been replaced with accessors. You just watch properties instead of the old event model they used in 3.x. Maybe Yann Cabon can chime in here.
Hi there,
There is no event fires in response to delete operation for sketch. We will look into it. In meantime, you can watch GraphicsLayer.graphics.length property as Robert Scheitlin, GISP to respond to delete.
Undral Batsukh, there IS an undocumented event that fires in response to a delete. See my previous reply with the code example (nb 'drawingTools' is of type 'Sketch').
My question is essentially - is this simply missing from the documentation?
My follow-on question is then, can I rely on it being there in the future?
(Robert Scheitlin, GISP it looks like the newer simplified set of events to my eyes)
No it is not documented. Not meant be used publicly.
Thank you Undral.
It is suspicious and inconsistent by its absence (as the other actions are as pairs of events and methods except 'reset()') - what are the plans for the future releases of the API?
For the benefit of anyone finding this thread, the reply that should have been:
ESRI: "Hi Nathan, yes it is an odd pattern. We have spoken to our developers and they have said it is an omission from the documentation, but for good reason. They will be adding a 'delete' event in 4.11, which means the undocumented 'reset' event will no longer exist"
Nathan: "Thanks ESRI, great answer"