igvteam / igv-webapp

IGV Web App
https://igv.org/app
MIT License
118 stars 44 forks source link

Accessing igv.js's "browser" object? #205

Closed whole-systems-enterprises closed 3 years ago

whole-systems-enterprises commented 3 years ago

Hi. igv-webapp is great software. When I load index.html into a window, how do I access the igv.js component's browser object from javascript? A crude hack is to make the variable global but that is inelegant and I figure you might have a better method? Thanks!

jrobinso commented 3 years ago

This really isn't part of the igv-webapp design, for an embeddable component see https://github.com/igvteam/igv.js. When you say "make the variable global" I'm not sure what you are referring to, but attaching the "browser" object to a global is one solution. You will note its attach to a "Globals" variable in line 83 of js/app.js, but that is not truly "global" its scope is within the app. However after building the es5 compatible package that variable should be accessible though the global "igv_webapp", so this might work

igv_webapp.Globals.browser

This is also a hack, I'm not sure its any better than your solution and I haven't tried it.