import { OperationQueueEntry } from "./OperationQueueEntry"; import { Operation, NextLink, Observable } from "apollo-link"; import { OfflineLinkOptions } from "../links"; export declare type OperationQueueChangeHandler = (entry: OperationQueueEntry) => void; /** * Class implementing persistent operation queue. * * This class is designed to be used by OfflineLink * It provides these functionalities: * * - persisting operation queue in provided storage * - updating client IDs with server IDs (explained below) */ export declare class OfflineQueue { queue: OperationQueueEntry[]; private readonly listener?; private readonly state?; private store; constructor(options: OfflineLinkOptions); /** * Persist entire queue with the new item to make sure that change * is going to be working across restarts */ persistItemWithQueue(operation: Operation): Promise; /** * Enqueue offline change and wait for it to be sent to server when online. * Every offline change is added to queue. * */ enqueueOfflineChange(operation: Operation, forward: NextLink): Observable<{}>; forwardOperations(): Promise; private onForwardError; private onForwardNext; /** * Allow updates on items created while offline. * If item is created while offline and client generated ID is provided * to optimisticResponse, later mutations on this item will be using this client * generated ID. Once any create operation is successful, we should * update entries in queue with ID returned from server. */ private updateIds; /** * Manipulate state of item that is being used for conflict resolution purposes. * This is required for the queue items so that we do not get a conflict with ourself * @param entry the operation which returns the result we compare with first queue entry */ private updateObjectState; }