Sketch widget Delete event (4.10)

1714
8
Jump to solution
02-05-2019 07:52 AM
NathanSummers1
New Contributor III

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...)

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
NathanSummers1
New Contributor III

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"

View solution in original post

0 Kudos
8 Replies
RobertScheitlin__GISP
MVP Emeritus
0 Kudos
NathanSummers1
New Contributor III

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.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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. 

0 Kudos
UndralBatsukh
Esri Regular Contributor

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. 

0 Kudos
NathanSummers1
New Contributor III

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)

0 Kudos
UndralBatsukh
Esri Regular Contributor

No it is not documented. Not meant be used publicly. 

0 Kudos
NathanSummers1
New Contributor III

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?

0 Kudos
NathanSummers1
New Contributor III

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"

0 Kudos