How to get IModelConnection in a Front-end App? #1724
-
If my front-end connects to a back-end given Context-Id & Model-Id, how can I get the associated IModelConnection? IModelApp does not seem to have an IModelConnection property. I can get an IModelConnection through its ViewManager property & through to its Selected VP. But it seems a roundabout way to get to the IModelConnection. I also get an IModelConnection through the 'onIModelConnected' callback on a Viewer React Control. But then I'll need to store this reference in some global or singleton object, which also seems a roundabout way. Is there a simpler, more obvious way to get an IModelConnection? Deepak. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
You can get it from UiFramework.getIModelConnection or useActiveIModelConnection hook. |
Beta Was this translation helpful? Give feedback.
-
Since you can open more than one iModel at a time, there is no such thing as "the" IModelConnection. For example, you can open more than one view, each showing a different iModel. Of course the IModelConnection doesn't get created magically; your app has to create it somewhere (e.g. CheckpointConnection.open), so your question amounts to "how do i find my IModelConnection". You can either save it somewhere when you create it, or use the viewManager techniques above. HTH, |
Beta Was this translation helpful? Give feedback.
Since you can open more than one iModel at a time, there is no such thing as "the" IModelConnection. For example, you can open more than one view, each showing a different iModel.
Of course the IModelConnection doesn't get created magically; your app has to create it somewhere (e.g. CheckpointConnection.open), so your question amounts to "how do i find my IModelConnection". You can either save it somewhere when you create it, or use the viewManager techniques above.
HTH,
Keith