Skip to content

Commit 34e0816

Browse files
committed
Use OnReadyResult from shared_types
1 parent df703c4 commit 34e0816

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

packages/optimizely-sdk/lib/core/project_config/project_config_manager.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ import { HttpPollingDatafileManager } from '@optimizely/js-sdk-datafile-manager'
2020
import fns from '../../utils/fns';
2121
import { ERROR_MESSAGES } from '../../utils/enums';
2222
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';
2429
import { ProjectConfig, toDatafile, tryCreatingProjectConfig } from '../project_config';
2530

2631
const logger = getLogger();
@@ -61,7 +66,7 @@ export class ProjectConfigManager {
6166
private updateListeners: Array<(config: ProjectConfig) => void> = [];
6267
private configObj: ProjectConfig | null = null;
6368
private optimizelyConfigObj: OptimizelyConfig | null = null;
64-
private readyPromise: Promise<{ success: boolean; reason?: string }>;
69+
private readyPromise: Promise<OnReadyResult>;
6570
public jsonSchemaValidator: { validate(jsonObject: unknown): boolean } | undefined;
6671
public datafileManager: HttpPollingDatafileManager | null = null;
6772

@@ -127,7 +132,7 @@ export class ProjectConfigManager {
127132
* config object from the new datafile, and its ready promise is resolved with a
128133
* successful result.
129134
*/
130-
private onDatafileManagerReadyFulfill(): { success: boolean; reason?: string } {
135+
private onDatafileManagerReadyFulfill(): OnReadyResult {
131136
if (this.datafileManager) {
132137
const newDatafileError = this.handleNewDatafile(this.datafileManager.get());
133138
if (newDatafileError) {
@@ -153,7 +158,7 @@ export class ProjectConfigManager {
153158
* @param {Error} err
154159
* @returns {Object}
155160
*/
156-
private onDatafileManagerReadyReject(err: Error): { success: boolean; reason: string } {
161+
private onDatafileManagerReadyReject(err: Error): OnReadyResult {
157162
return {
158163
success: false,
159164
reason: getErrorMessage(err, 'Failed to become ready'),
@@ -254,7 +259,7 @@ export class ProjectConfigManager {
254259
* an explanatory message.
255260
* @return {Promise}
256261
*/
257-
onReady(): Promise<{ success: boolean; reason?: string }> {
262+
onReady(): Promise<OnReadyResult> {
258263
return this.readyPromise;
259264
}
260265

0 commit comments

Comments
 (0)