Skip to content

Move sync change-tracking callback wiring to SDK SyncDomainTracker #29

@variablefate

Description

@variablefate

Context

SyncCoordinator currently hardcodes the mapping of "when this changes, mark that domain dirty":

settings.onProfileChanged = { store?.markDirty(.profile) }
driversRepo.onDriversChanged = { source in
    guard source == .local else { return }
    store?.markDirty(.followedDrivers)
}

This is protocol semantics — "profile name changes → Kind 0 sync needed" — that the SDK should own. The app shouldn't be thinking about which Nostr event kinds correspond to which domain changes.

What needs doing

  1. Create SyncDomainTracker (or extend RoadflareSyncStateStore) in the SDK
  2. Move change-tracking callback setup into SDK: tracker.wireCallbacks(settings:, drivers:, ...)
  3. The SDK defines the mapping: settings changes → profile dirty, driver changes → followedDrivers dirty, etc.
  4. Simplify app-layer SyncCoordinator to call tracker.wireCallbacks() during setup
  5. Keep performStartupSync() and flushPendingSyncPublishes() in SyncCoordinator as-is (correct app-layer orchestration)

Why this matters

Pattern reference

SyncDomainResolver already owns the resolution logic in the SDK. SyncDomainTracker would own the detection side, completing the SDK's ownership of the sync lifecycle.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions