@@ -68,8 +68,31 @@ import {
68
68
import '@jupyter-widgets/base/css/index.css' ;
69
69
import '@jupyter-widgets/controls/css/widgets-base.css' ;
70
70
import { KernelMessage } from '@jupyterlab/services' ;
71
+ import { ISignal , Signal } from '@lumino/signaling' ;
71
72
72
- const WIDGET_REGISTRY : base . IWidgetRegistryData [ ] = [ ] ;
73
+ class WidgetRegistry {
74
+ get widgets ( ) : base . IWidgetRegistryData [ ] {
75
+ return [ ...this . _registry ] ;
76
+ }
77
+
78
+ push ( data : base . IWidgetRegistryData ) {
79
+ this . _registry . push ( data ) ;
80
+ this . _widgetRegistered . emit ( data ) ;
81
+ }
82
+
83
+ get widgetRegistered ( ) : ISignal < WidgetRegistry , base . IWidgetRegistryData > {
84
+ return this . _widgetRegistered ;
85
+ }
86
+
87
+ private _widgetRegistered = new Signal <
88
+ WidgetRegistry ,
89
+ base . IWidgetRegistryData
90
+ > ( this ) ;
91
+
92
+ private _registry : base . IWidgetRegistryData [ ] = [ ] ;
93
+ }
94
+
95
+ const WIDGET_REGISTRY = new WidgetRegistry ( ) ;
73
96
74
97
/**
75
98
* The cached settings.
@@ -126,7 +149,10 @@ export function registerWidgetManager(
126
149
let wManager = Private . widgetManagerProperty . get ( context ) ;
127
150
if ( ! wManager ) {
128
151
wManager = new WidgetManager ( context , rendermime , SETTINGS ) ;
129
- WIDGET_REGISTRY . forEach ( data => wManager . register ( data ) ) ;
152
+ WIDGET_REGISTRY . widgets . forEach ( data => wManager . register ( data ) ) ;
153
+ WIDGET_REGISTRY . widgetRegistered . connect ( ( _ , data ) => {
154
+ wManager . register ( data ) ;
155
+ } ) ;
130
156
Private . widgetManagerProperty . set ( context , wManager ) ;
131
157
}
132
158
0 commit comments