Skip to content

Commit fb4b801

Browse files
committed
refactor: simplify inAppManager initialization to avoid circular dependencies
1 parent 39f07d0 commit fb4b801

1 file changed

Lines changed: 5 additions & 24 deletions

File tree

src/core/classes/Iterable.ts

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,23 @@ import { Linking, NativeEventEmitter, Platform } from 'react-native';
33
import { buildInfo } from '../../itblBuildInfo';
44

55
import { RNIterableAPI } from '../../api';
6-
// TODO: Organize these so that there are no circular dependencies
7-
// See https://github.com/expo/expo/issues/35100
6+
import { IterableInAppManager } from '../../inApp/classes/IterableInAppManager';
87
import { IterableInAppMessage } from '../../inApp/classes/IterableInAppMessage';
98
import { IterableInAppCloseSource } from '../../inApp/enums/IterableInAppCloseSource';
109
import { IterableInAppDeleteSource } from '../../inApp/enums/IterableInAppDeleteSource';
1110
import { IterableInAppLocation } from '../../inApp/enums/IterableInAppLocation';
1211
import { IterableAuthResponseResult } from '../enums/IterableAuthResponseResult';
1312
import { IterableEventName } from '../enums/IterableEventName';
14-
15-
// Add this type-only import to avoid circular dependency
16-
import type { IterableInAppManager } from '../../inApp/classes/IterableInAppManager';
17-
13+
import type { IterableAuthFailure } from '../types/IterableAuthFailure';
1814
import { IterableAction } from './IterableAction';
1915
import { IterableActionContext } from './IterableActionContext';
16+
import { IterableApi } from './IterableApi';
2017
import { IterableAttributionInfo } from './IterableAttributionInfo';
18+
import { IterableAuthManager } from './IterableAuthManager';
2119
import { IterableAuthResponse } from './IterableAuthResponse';
2220
import type { IterableCommerceItem } from './IterableCommerceItem';
2321
import { IterableConfig } from './IterableConfig';
2422
import { IterableLogger } from './IterableLogger';
25-
import type { IterableAuthFailure } from '../types/IterableAuthFailure';
26-
import { IterableAuthManager } from './IterableAuthManager';
27-
import { IterableApi } from './IterableApi';
2823

2924
const RNEventEmitter = new NativeEventEmitter(RNIterableAPI);
3025

@@ -75,21 +70,7 @@ export class Iterable {
7570
* Iterable.inAppManager.showMessage(message, true);
7671
* ```
7772
*/
78-
static get inAppManager() {
79-
// Lazy initialization to avoid circular dependency
80-
if (!this._inAppManager) {
81-
// Import here to avoid circular dependency at module level
82-
83-
const {
84-
IterableInAppManager,
85-
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-require-imports
86-
} = require('../../inApp/classes/IterableInAppManager');
87-
this._inAppManager = new IterableInAppManager();
88-
}
89-
return this._inAppManager;
90-
}
91-
92-
private static _inAppManager: IterableInAppManager | undefined;
73+
static inAppManager: IterableInAppManager = new IterableInAppManager();
9374

9475
/**
9576
* Authentication manager for the current user.

0 commit comments

Comments
 (0)