UNPKG

connect-transfer-react-native-sdk

Version:

Connect Transfer React Native SDK for Mastercard Open Banking Connect

45 lines 1.66 kB
/** * EventQueue - A singleton class that ensures audit events are processed one at a time * in the order they are received. * * This prevents race conditions and ensures no audit event api is missed * even with rapid or repeated user actions. */ import { AuditEventData, EventTask } from '../intefaces'; declare class EventQueue { private queue; private isProcessing; private isDestroyed; /** * Enqueues a new event data and starts the processing loop if not already running. * * @param data - The data task to enqueue * @param processFn - A function that processes each event data (e.g., dispatch) */ enqueue(data: EventTask, processFn: (data: EventTask) => Promise<void>): void; /** * Processes events in the queue one by one in FIFO order. * Prevents concurrent processing via the `isProcessing` flag. */ private processQueue; destroy(): void; reset(): void; } /** * Singleton instance of the EventQueue * This ensures all events are handled in one centralized queue * even if `queueAuditEvent` is called from multiple parts of the app. */ export declare const eventQueue: EventQueue; /** * Call this function instead of directly dispatching auditEvents. * This ensures the audit event api is queued and processed sequentially. */ export declare const queueAuditEvent: (data: AuditEventData) => void; /** * Hook to map and queue audit events in one call. * Can be used inside React components only. */ export declare const useSendAuditData: () => (eventName: string, eventData?: Record<string, any>) => void; export {}; //# sourceMappingURL=auditEventQueue.d.ts.map