UNPKG

@clix-so/react-native-sdk

Version:
58 lines (57 loc) 1.35 kB
"use strict"; import { ClixLogger } from "../utils/logging/ClixLogger.js"; export class ClixInitCoordinator { resolve = null; reject = null; isCompleted = false; isFailed = false; constructor() { this.promise = new Promise((resolve, reject) => { this.resolve = resolve; this.reject = reject; }); } async waitForInitialization() { if (this.isCompleted) { return Promise.resolve(); } return this.promise; } isInitializationFailed() { return this.isFailed; } isInitializationCompleted() { return this.isCompleted; } completeInitialization() { if (this.isAlreadyFinalized()) { return; } this.isCompleted = true; this.resolve?.(); } failInitialization(error) { if (this.isAlreadyFinalized()) { return; } this.isFailed = true; ClixLogger.warn('Clix initialization failed:', error); this.reject?.(error); } reset() { this.isCompleted = false; this.isFailed = false; this.promise = new Promise((resolve, reject) => { this.resolve = resolve; this.reject = reject; }); } isAlreadyFinalized() { if (this.isCompleted || this.isFailed) { ClixLogger.warn('Initialization already completed or failed'); return true; } return false; } } //# sourceMappingURL=ClixInitCoordinator.js.map