orb icon indicating copy to clipboard operation
orb copied to clipboard

Fix the Typescript usage of the view settings

Open tonilastre opened this issue 3 years ago • 0 comments

Issue: Typescript interface is not correctly applied to view (DefaultView, MapView) settings

Details can be read on Stackoverflow: How to setup typescript generics in class constructors and functions

The problem is that main orb object handles different views through orb.setView where each view can have different settings so orb.view.setSettings is not able to apply correct Typescript interface (at least with the current latest TS version).

The solution could be to create a new instance on view changes, e.g.

const orb = new Orb({ generalSettings });

const view = orb.createView((context) => new DefaultView(container1, { viewSettings }));

// Use view from now on
view.render(() => {
  view.recenter();
});

const newView = orb.createView((context) => new MapView(container2, { viewSettings }));

tonilastre avatar Sep 16 '22 19:09 tonilastre