Skip to content

Commit 6feec35

Browse files
committed
feat: add in-app message manager with lazy initialization to avoid circular dependency
1 parent 1873f0f commit 6feec35

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/core/classes/Iterable.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import { IterableInAppDeleteSource } from '../../inApp/enums/IterableInAppDelete
1515
import { IterableInAppLocation } from '../../inApp/enums/IterableInAppLocation';
1616
import { IterableAuthResponseResult, IterableEventName } from '../enums';
1717

18+
// Add this type-only import to avoid circular dependency
19+
import type { IterableInAppManager } from '../../inApp/classes/IterableInAppManager';
20+
1821
import { IterableAction } from './IterableAction';
1922
import { IterableActionContext } from './IterableActionContext';
2023
import { IterableAttributionInfo } from './IterableAttributionInfo';
@@ -56,6 +59,36 @@ export class Iterable {
5659
*/
5760
static savedConfig: IterableConfig = new IterableConfig();
5861

62+
/**
63+
* In-app message manager for the current user.
64+
*
65+
* This property provides access to in-app message functionality including
66+
* retrieving messages, displaying messages, removing messages, and more.
67+
*
68+
* @example
69+
* ```typescript
70+
* // Get all in-app messages
71+
* Iterable.inAppManager.getMessages().then(messages => {
72+
* console.log('Messages:', messages);
73+
* });
74+
*
75+
* // Show a specific message
76+
* Iterable.inAppManager.showMessage(message, true);
77+
* ```
78+
*/
79+
static get inAppManager() {
80+
// Lazy initialization to avoid circular dependency
81+
if (!this._inAppManager) {
82+
// Import here to avoid circular dependency at module level
83+
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-require-imports
84+
const { IterableInAppManager } = require('../../inApp/classes/IterableInAppManager');
85+
this._inAppManager = new IterableInAppManager();
86+
}
87+
return this._inAppManager;
88+
}
89+
90+
private static _inAppManager: IterableInAppManager | undefined;
91+
5992
/**
6093
* Initializes the Iterable React Native SDK in your app's Javascript or Typescript code.
6194
*

0 commit comments

Comments
 (0)