Fetching & Displaying Data

What is the recommended approach for handling offline data synchronization?
class OfflineSync {
  constructor() {
    this.queue = new Queue();
    this.db = new IndexedDB('offlineStore');
  }

  async enqueue(operation) {
    await this.db.add(operation);
    if (navigator.onLine) {
      this.processQueue();
    }
  }

  async processQueue() {
    while (await this.queue.hasItems()) {
      const operation = await this.queue.dequeue();
      try {
        await this.syncOperation(operation);
        await this.db.remove(operation.id);
      } catch (error) {
        if (!isRetryableError(error)) {
          await this.handleSyncError(operation, error);
        }
      }
    }
  }
Next Question (19/20)