@@ -3,6 +3,7 @@ import { IDocumentWidget } from '@jupyterlab/docregistry';
3
3
import { ISettingRegistry } from '@jupyterlab/settingregistry' ;
4
4
import { TranslationBundle } from '@jupyterlab/translation' ;
5
5
import { LabIcon } from '@jupyterlab/ui-components' ;
6
+ import { PromiseDelegate } from '@lumino/coreutils' ;
6
7
import { Signal } from '@lumino/signaling' ;
7
8
8
9
import { StatusMessage , WidgetAdapter } from './adapters/adapter' ;
@@ -65,32 +66,34 @@ export interface IFeatureSettings<T> {
65
66
export class FeatureSettings < T > implements IFeatureSettings < T > {
66
67
protected settings : ISettingRegistry . ISettings ;
67
68
public changed : Signal < FeatureSettings < T > , void > ;
68
- public ready : Promise < void > ;
69
+ private _ready = new PromiseDelegate < void > ( ) ;
69
70
70
71
constructor ( protected settingRegistry : ISettingRegistry , featureID : string ) {
71
72
this . changed = new Signal ( this ) ;
72
73
if ( ! ( featureID in settingRegistry . plugins ) ) {
73
- console . warn (
74
+ this . _ready . reject (
74
75
`${ featureID } settings schema could not be found and was not loaded`
75
76
) ;
76
77
} else {
77
- this . ready = new Promise ( accept => {
78
- settingRegistry
79
- . load ( featureID )
80
- . then ( settings => {
78
+ settingRegistry
79
+ . load ( featureID )
80
+ . then ( settings => {
81
+ this . settings = settings ;
82
+ this . _ready . resolve ( void 0 ) ;
83
+ this . changed . emit ( ) ;
84
+ settings . changed . connect ( ( ) => {
81
85
this . settings = settings ;
82
- accept ( ) ;
83
86
this . changed . emit ( ) ;
84
- settings . changed . connect ( ( ) => {
85
- this . settings = settings ;
86
- this . changed . emit ( ) ;
87
- } ) ;
88
- } )
89
- . catch ( console . warn ) ;
90
- } ) ;
87
+ } ) ;
88
+ } )
89
+ . catch ( console . warn ) ;
91
90
}
92
91
}
93
92
93
+ get ready ( ) : Promise < void > {
94
+ return this . _ready . promise ;
95
+ }
96
+
94
97
get composite ( ) : Required < T > {
95
98
return this . settings . composite as unknown as Required < T > ;
96
99
}
0 commit comments