haystack-nclient
Version:
Project Haystack Network Client
49 lines (48 loc) • 1.46 kB
TypeScript
import { NotificationService, NotificationEventHandler } from './NotificationService';
export declare class NotificationsHandler {
#private;
constructor({ notificationService, callbacks, }: {
notificationService: NotificationService;
callbacks: NotificationEventHandler[];
});
/**
* Opens the connection(s) to receive notifications
*/
open(): Promise<void>;
/**
* Connect to the EventSource API and attach event handlers
* @param client Client - The Haystack Client
*/
private start;
/**
* On push notification event, parse result and update store
* @param event MessageEvent
*/
private onNotificationReceived;
/**
* Calls the callbacks when new notification(s) received
* @param notifications Notifications[]
*/
private callNotificationHandlers;
/**
* On push notification error, close EventSource and begin poll
* @param client Client
*/
private onNotificationPushError;
/**
* Starts a poll on the notifications API, sorting
* the requested notifications by time
* @param client Client - The Haystack Client
*/
private initializePoll;
private setLastNotificationUpdateTime;
private poll;
/**
* Close EventSource API connection and stop API Polling
*/
close(): void;
/**
* @throws An error if the watch is closed.
*/
private throwErrorIfClosed;
}