Select to view content in your preferred language

4.29 - ApplyEdits callback BEFORE visible on the MAP ISSUE

739
2
02-02-2024 04:33 AM
michaelkdev
Regular Contributor

Hi. It seems like featureLayer.applyEdits returns a result when the data is processed by the api but not actual visible on the map.

To reproduce this, I made a codepen with a loop creating events/messages/graphicupdates each 10 ms - 1000 ms. These messages will be merged into 1 BUFFER (being a subject). 

Snippet:

 

 

from(updates).pipe(
            concatMap(item => of (item).pipe(delay(100))), // UPDATES TRIGGERED EACH 100 ms -> could be random between 10-300 ms
            tap(() => { 
                    ... // merge logic so no updates will be lost
                    bufferSubject.next(currentBuffer); 
            })
).subscribe();

 

 2. A subscription of the bufferSubject (asObservable)

 

 bufferSubject.asObservable()
          .pipe(
            skipWhile(() => dataAppliedSubject.value), //Made a dataAppliedSubject -> while applying this buffer, next one will be skipped
            filter((buffer) => buffer.length > 0),
            concatMap(async (buffer) => {
              dataAppliedSubject.next(true);
              return applyDataToMap(layer, buffer) // applyEdits logic async from ArcGis API
            }),
            tap((res) => {
              // THIS should only be triggered when APPLYEDITS is fully processed. But it looks like its not fully rendered on the map -> This will be an issue
              dataAppliedSubject.next(false); // When applied -> ready for next buffer
            })
          )
          .subscribe();

 


ISSUE:
When I change the delay to 300. The updates are being displayed without any problems or lagg. 
When changing the delay to 10. The updates are processed way too fast and it stops working. (no changes visible on the map). 

Approach: 
Maybe the applyEdits should only return results when they are fully processed by the api AND fully DRAWN on the map?

https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#event-ed...

"Fires after applyEdits() is completed successfully." Looks like it's not 100% correct

Is it possible to achieve this?

Codepen:

https://codepen.io/michaelk95/pen/GRexMJR?editors=1000

Thanks

0 Kudos
2 Replies
michaelkdev
Regular Contributor

Example of ArcGIS mapView being stuck when processing too much data. Because view.updating + applyEdits callback != drawn on the map. 

https://codepen.io/michaelk95/pen/YzgLzaZ?editors=1000

0 Kudos
UndralBatsukh
Esri Regular Contributor

Hi there, 

I did not quite exactly follow the issue you are reporting here. It seems like the problem is applyEdits performance when being called frequently? If so applyEdits method is not meant to be used with such high frequency. If you are updating feature frequently then consider using StreamLayer instead. 

This document talks about different ways of creating stream layer: https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#creating-...

 

 

0 Kudos