ArcGIS JS - 4.16 - Bookmark Widget - onAdd event

1432
4
Jump to solution
07-29-2020 11:20 PM
GeorgeAbraham
New Contributor III

Hi Team,

I need to implement a functionality of saving the newly created bookmarks. I see in he old 3.33 version using esri/digit there is an option implemented to store in the client but I can use the same to take the value and pass it to my custom service.

However for the new 4.16 library, I don't see any event for edit/remove etc or even for add.

How can I achieve this with the new library?

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

Read more about watch here:

Programming patterns | ArcGIS API for JavaScript 4.16 

However, since the bookmarks property is a collection, you have to set an event handler.

Not all properties can be watched, including collections. Register an event handler to be notified of changes to a collection.

Note: Because both the FeatureLayer.source and GraphicsLayer.graphics properties are collections, use on() instead of watch() to be notified of changes to the values of these properties.

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Emeritus

George,

   In 4.x you would Watch the bookmarks property. Many things that were Event'd in 3.x are not in 4.x as you can just watch properties for changes.

KenBuja
MVP Esteemed Contributor

Read more about watch here:

Programming patterns | ArcGIS API for JavaScript 4.16 

However, since the bookmarks property is a collection, you have to set an event handler.

Not all properties can be watched, including collections. Register an event handler to be notified of changes to a collection.

Note: Because both the FeatureLayer.source and GraphicsLayer.graphics properties are collections, use on() instead of watch() to be notified of changes to the values of these properties.

GeorgeAbraham
New Contributor III

Thanks a lot Robert Scheitlin, GISPand Ken Buja! You guys are awesome. These pointers actually helps me clear some of my concepts and main confusion with how the watch and on worked and this makes sense.

Since I am mainly concerned with the BookmarksWidget.bookmarks Collection, I will go with the .on("change") and play around with it.

I just have a concern on how it will trigger for edit operation as I see only event.added, event.moved and event.removed while there is an Edit operation allowed for bookmarks. I will check if the its getting captured in the added, if not, I will reach out to either of you.

0 Kudos
MohammedZaki
New Contributor III

Hello @GeorgeAbraham , did you find it out? how to trigger for add, remove, and edit?

0 Kudos