iTwin / itwinjs-core

Monorepo for iTwin.js Library
https://www.itwinjs.org
MIT License
615 stars 210 forks source link

Provide an API that would report any map-layer authentication issue to UI #4683

Open mdastous-bentley opened 1 year ago

mdastous-bentley commented 1 year ago

Currently when a new layer is added, MapLayerSource.validateSource() can be used upfront to determine if a given map-layer will require authentication. While this works fine for newly added layer, that doesn't prevent a layer to go from a valid state to an invalid one : for example after some time, the token might expire, and the authentication process needs to occur again.

MapLayerImageryProvider is the closest object to the external data source, and knows when a given map-layer needs authentication by inspecting the request response object. There is currently an 'MapLayerImageryProvider.onStatusChanged' event on every imagery provider instance. This API is problematic because it forces the UI to lookup every Map-layer's provided, and listen to every 'MapLayerImageryProvider.onStatusChanged' events.

Ideally we would have a single event, providing enough information to the UI so that it can determine quickly which layer needs to be re-authenticated.

mdastous-bentley commented 1 year ago

@pmconne Knowing the map-layers widget is interested in one viewport at a time, I can add a new event on a object like MapTiledGraphicsProvider (each viewports have its own instance)... however I don't get how the different MapLayerImageryProvider objects are going to reach the right MapTiledGraphicsProvider object in order to signal a status change... assuming a MapLayerImageryProvider object can be shared across viewports.

ben-polinsky commented 1 year ago

@mdastous-bentley Any update? Is this on your radar?

mdastous-bentley commented 1 year ago

@ben-polinsky Not a high priority for me, is this causing any issues?

ben-polinsky commented 1 year ago

No, just doing some cleanup and triage of issues and wanted to see the status.