graphicsLayer.remove*() not synchronous

95
1
04-02-2020 06:32 PM
AlexPoon
New Contributor

By definition, these functions has no output values:

* remove(graphic)

* removeAll()

* removeMany(graphics)

From my observation, they return before the graphics are actually removed. Geez, they should have used promise instead! If I want to do some geometric operations afterwards, how should I be notified when the graphics are actually removed?

Tags (2)
0 Kudos
1 Reply
UndralBatsukh
Esri Regular Contributor

Hi there, 

You should listen to events on your graphics collection. You can capture them as shown below:

layer.graphics.on(["before-remove", "after-remove"], function(event){
// process your logic here before and after the graphic is removed
});

layer.graphics.on("after-remove", function(event){
// process your logic here after the graphic is removed
});