I want to integrate an ES6 Dependency (vtk.js) into a Qooxdoo Application. I don't know how to manage this. Here is an Example to use the vtk.js. So my Question is:
The short answer is yes, with some caveats. Qooxdoo v5 (the current release) does not support ES6 constructs in code, because (a) the generator will not accept that syntax and (b) ES6 requires strict mode and there's a compatibility issue which prevents it working.
You could use Qooxdoo v5 with an ES6 library, provided that you don't want to write ES6 code yourself - strict mode is specified on a per-file basis, and your only restriction is to not enable it on code which the generator compiles (ie your code).
However, Qooxdoo v6 supports ES6 out of the box, provided that you use the new compiler (at github.com/qooxdoo-compiler). This compiler will allow you to write ES6 code and transpile it on the fly so that you can also achieve platform independence.
Qooxdoo v6 is in beta and available via github.com/qooxdoo - the master branch is very stable and used in production by core team members so is worth consideration.
In v6 you can customise the index.html generation, or use the externalResources
key in compile.json
(if you're using the compiler) or handle loading yourself via qx.io.DynamicScriptLoader
.
Once the javascript is loaded, you then need to create a custom class derived from qx.ui.core.Widget
and override these methods:
_createContentElement
- override this method to create the DOM element that implements your widget, i.e. this is where you would initialise a VTK instance_getContentHint()
- this returns a map of preferred height & width for the widget; it's job is to tell the Qooxdoo layout engine how big the widget would like to berenderLayout
- this method is called to make the element appear on screen and at a given size and position - in practice, this means that you use this method to modify the dimensions of the DOM element which implements your custom widgetOnce you've done that, you will have a custom widget that integrates with Qooxdoo; all that remains is to either expose the internal VTK implementation or build an API to operate VTK through.