You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe it's a minority requirement, But I try to use it to achieve a pluggable app.
I am writing a page designer which is a wysiwyg ui editor, I want the designer can load and render third party custom widgets at runtime.
Have two dojo app:
first is the app1 which was built with dojo build --mode dist
second is the library1 which is also a dojo app, but was built with dojo build --mode dist --single-bundle
app1 is the main app which need to load the third party library by extension(at runtime, not use npm install).
library1 is the third party dojo app which contains custom dojo widgets. library1 has a function to export it's widgets called getWidget(widgetPath: string) which return a widget type.
I try to use <script src=""></script> inject library1 to app1's index.html, then app1 can use library1's widgets to render them, I call the app1 is the pluggable app.
All is fine, but only one thing when app1 renders library1's widgets. I debug it and fount that
Here use a app scope variable export const widgetInstanceMap
so when library1 called below code to instance a widget, it was stored in the widgetInstanceMap which was in library1 scope, and app1's widgetInstanceMap do not found third party library's widgets
// app1 found a widget which in libaray1's widgetInstanceMap// so instanceData is nullconstinstanceData=widgetInstanceMap.get(instance)!;
...
instanceData.invalidate=invalidate;
because instanceData is null, so throw a null error.
Then I override library1's widgetInstanceMap's set method
The app1 found library1's widgets now, and app1 render library1's widget correctly.
Package Version: v6.0
Expected behavior:
The app1's widgetInstanceMap can store the library1's widgetInstanceMap, because in pluggable app, library1 not need to dependent dojo framework, and library1's widgetInstanceMap not need to store the widget instances.
maybe define the widgetInstanceMap like widgetMetaMap(I'm not sure)
// not contains `export`constwidgetMetaMap=newMap<string,WidgetMeta>();
May be need to export widgetMetaMap
maybe then pass widgetInstanceMap to Constructor, so the WidgetBase can use it.
Actual behavior:
app1 and library1 have it's own widgetInstanceMap.
Thanks!
The text was updated successfully, but these errors were encountered:
xiaohulu
changed the title
What happen when I try
What happen when I try to implement a pluggable app
Oct 23, 2019
xiaohulu
changed the title
What happen when I try to implement a pluggable app
What happen when I try to achieve a pluggable app which can load third party library at runtime
Oct 23, 2019
xiaohulu
changed the title
What happen when I try to achieve a pluggable app which can load third party library at runtime
Throw one error when I try to achieve a pluggable app which can load third party library at runtime
Oct 23, 2019
Enhancement
Maybe it's a minority requirement, But I try to use it to achieve a pluggable app.
I am writing a page designer which is a wysiwyg ui editor, I want the designer can load and render third party custom widgets at runtime.
Have two dojo app:
app1
which was built withdojo build --mode dist
library1
which is also a dojo app, but was built withdojo build --mode dist --single-bundle
app1
is the main app which need to load the third party library by extension(at runtime, not use npm install).library1
is the third party dojo app which contains custom dojo widgets.library1
has a function to export it's widgets calledgetWidget(widgetPath: string)
which return a widget type.I try to use
<script src=""></script>
injectlibrary1
toapp1
'sindex.html
, thenapp1
can uselibrary1
's widgets to render them, I call theapp1
is the pluggable app.All is fine, but only one thing when
app1
renderslibrary1
's widgets. I debug it and fount thatframework/src/core/vdom.ts
Line 799 in 8334cbe
Here use a app scope variable
export const widgetInstanceMap
so when
library1
called below code to instance a widget, it was stored in thewidgetInstanceMap
which was inlibrary1
scope, andapp1
'swidgetInstanceMap
do not found third party library's widgetsbecause instanceData is null, so throw a null error.
Then I override
library1
's widgetInstanceMap'sset
methodThen watching
library1
's widgetInstanceMap inapp1
The
app1
foundlibrary1
's widgets now, andapp1
renderlibrary1
's widget correctly.Package Version: v6.0
Expected behavior:
The
app1
's widgetInstanceMap can store thelibrary1
's widgetInstanceMap, because in pluggable app,library1
not need to dependent dojo framework, andlibrary1
's widgetInstanceMap not need to store the widget instances.maybe define the
widgetInstanceMap
likewidgetMetaMap
(I'm not sure)May be need to export
widgetMetaMap
maybe then pass
widgetInstanceMap
toConstructor
, so theWidgetBase
can use it.Actual behavior:
app1
andlibrary1
have it's ownwidgetInstanceMap
.Thanks!
The text was updated successfully, but these errors were encountered: