@@ -20,7 +20,12 @@ import { HttpPollingDatafileManager } from '@optimizely/js-sdk-datafile-manager'
20
20
import fns from '../../utils/fns' ;
21
21
import { ERROR_MESSAGES } from '../../utils/enums' ;
22
22
import { createOptimizelyConfig } from '../optimizely_config' ;
23
- import { OptimizelyConfig , DatafileOptions , DatafileManagerConfig } from '../../shared_types' ;
23
+ import {
24
+ DatafileManagerConfig ,
25
+ DatafileOptions ,
26
+ OnReadyResult ,
27
+ OptimizelyConfig
28
+ } from '../../shared_types' ;
24
29
import { ProjectConfig , toDatafile , tryCreatingProjectConfig } from '../project_config' ;
25
30
26
31
const logger = getLogger ( ) ;
@@ -61,7 +66,7 @@ export class ProjectConfigManager {
61
66
private updateListeners : Array < ( config : ProjectConfig ) => void > = [ ] ;
62
67
private configObj : ProjectConfig | null = null ;
63
68
private optimizelyConfigObj : OptimizelyConfig | null = null ;
64
- private readyPromise : Promise < { success : boolean ; reason ?: string } > ;
69
+ private readyPromise : Promise < OnReadyResult > ;
65
70
public jsonSchemaValidator : { validate ( jsonObject : unknown ) : boolean } | undefined ;
66
71
public datafileManager : HttpPollingDatafileManager | null = null ;
67
72
@@ -127,7 +132,7 @@ export class ProjectConfigManager {
127
132
* config object from the new datafile, and its ready promise is resolved with a
128
133
* successful result.
129
134
*/
130
- private onDatafileManagerReadyFulfill ( ) : { success : boolean ; reason ?: string } {
135
+ private onDatafileManagerReadyFulfill ( ) : OnReadyResult {
131
136
if ( this . datafileManager ) {
132
137
const newDatafileError = this . handleNewDatafile ( this . datafileManager . get ( ) ) ;
133
138
if ( newDatafileError ) {
@@ -153,7 +158,7 @@ export class ProjectConfigManager {
153
158
* @param {Error } err
154
159
* @returns {Object }
155
160
*/
156
- private onDatafileManagerReadyReject ( err : Error ) : { success : boolean ; reason : string } {
161
+ private onDatafileManagerReadyReject ( err : Error ) : OnReadyResult {
157
162
return {
158
163
success : false ,
159
164
reason : getErrorMessage ( err , 'Failed to become ready' ) ,
@@ -254,7 +259,7 @@ export class ProjectConfigManager {
254
259
* an explanatory message.
255
260
* @return {Promise }
256
261
*/
257
- onReady ( ) : Promise < { success : boolean ; reason ?: string } > {
262
+ onReady ( ) : Promise < OnReadyResult > {
258
263
return this . readyPromise ;
259
264
}
260
265
0 commit comments