how to access JetView created via layout.addView?

https://snippet.webix.com/uvd46avg
in this snippet JetView is created by layout.addView passing class as argument
I need to get created instance.
is there any convenient way to achieve that?

Hey @intregal, please take a look at the snippet below, I’ve included a few possible scenarios: https://snippet.webix.com/g6mnps7h.
In the first case we are getting the Webix view created by your JetView instance.
In the second case we are getting the actual JetView instance itself, however, since the JetView creation is asyncronous, you have to use setTimeout() to get the object, in this case, we’ve used webix.delay() (basically the same old setTimeout() in a wrapper).

thank you @Dzmitry
what about this sync method

        { view:"button", value:"Add View", click:() => {
          let root = this.getRoot();
          let view = this.app.createView(FormView);
          root.addView(view);
        }}

may it cause any inconvenience?

Your way of doing this is also very valid, it shouldn’t cause any problems, not that we know of.

Solution with this.app.createView must be preferred to setTimeout/delay as async operations can take not predictable amount of time ( it works in the snippet, but may not work for real life use-cases ).

Current behavior of addView ( return id of non-existing view ) looks as a bug. Still, so far we have not find a way to fix it, as view rendering is really an async process and there is not stable way to return the id of new UI element in the sync way. ( we can change code to return promise of such id, but it will break API contract of the addView method )

thanks @maksim
in real scenario our views use async configs and I need the instance of JetView and not of its root.
so createView suits my needs.

p.s.: layout.addView can be repaired in patch.ts of Jet source.