Skip to main content

πŸ”„ Manual Refresh

Need to manually trigger a refresh? Use these from:

import {
refreshTable,
refreshAllTables,
} from "supastash/utils/sync/refreshTables";

πŸ” refreshTable(table: string): void​

For refreshing one table's local data:

refreshTable("orders");

Emits a refresh:orders event. Re-fetches local rows + triggers UI update.

πŸ” refreshAllTables(): void​

Refreshes everything:

refreshAllTables();

Good after a full sync or reset.

⚠️ refreshTableWithPayload() (Deprecated)​

This used to manually reflect data in the UI. No longer needed β€” use Supastash queries or refreshTable().

// Deprecated β€” avoid
refreshTableWithPayload("orders", { id: "abc", ... }, "update");

πŸ” Behind the Scenes​

  • πŸ” Supastash uses a version-based cache: if nothing changes, no re-renders.
  • 🧼 Realtime listeners are de-duped per table + filter.
  • ⚑ Flushes UI updates only after debounce (default 100ms).
  • 🧠 Grouped maps (via extraMapKeys) use Map<string, R[]>.

πŸ’‘ Best Practices​

  • Use dataMap for instant lookups (e.g., dataMap.get(id))
  • Use groupedBy.chat_id for message grouping
  • Use lazy: true in modal screens or deeply nested routes
  • Bump flushIntervalMs higher if syncing high-volume tables
  • Leverage onPushToRemote for custom API pipelines

πŸ”— What’s Next​