Skip to content

Conversation

grdsdev
Copy link
Contributor

@grdsdev grdsdev commented Sep 30, 2025

Summary

  • Added ReplayOption struct for configuring broadcast replay
  • Added replay field to BroadcastJoinConfig
  • Added public initializer to BroadcastJoinConfig to support replay configuration

Changes

This PR implements broadcast replay support following the pattern from realtime-js PR #540:

  1. ReplayOption: New struct with since (Int) and optional limit (Int?)
  2. BroadcastJoinConfig: Added optional replay field
  3. Public initializer: Added to enable replay configuration

Usage

// Configure broadcast with replay
let config = RealtimeJoinConfig(
  broadcast: BroadcastJoinConfig(
    acknowledgeBroadcasts: true,
    receiveOwnBroadcasts: true,
    replay: ReplayOption(
      since: 1234567890,
      limit: 100
    )
  )
)

let channel = supabase.realtimeV2.channel("my-channel", config: config)

// Broadcast callback receives meta field
channel.onBroadcast { message in
  if let meta = message.payload["meta"] as? [String: Any],
     let replayed = meta["replayed"] as? Bool,
     replayed {
    print("Replayed message: \(meta["id"] ?? "")")
  }
}

await channel.subscribe()

Test plan

  • Verify type checking passes
  • Test broadcast replay configuration
  • Verify meta field is properly included in callbacks

🤖 Generated with Claude Code

Added ReplayOption struct and replay field to BroadcastJoinConfig
to support configuring broadcast replay with 'since' timestamp and optional
'limit' parameter. Broadcast callbacks will automatically receive meta field
with replayed status and message id when replay is enabled.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@grdsdev grdsdev force-pushed the feat/broadcast-replay-support branch from 17f1c14 to 48a77d5 Compare September 30, 2025 19:31
@grdsdev grdsdev requested review from edgurgel and a team September 30, 2025 19:32
@coveralls
Copy link

Pull Request Test Coverage Report for Build 18141289223

Details

  • 5 of 9 (55.56%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.03%) to 77.778%

Changes Missing Coverage Covered Lines Changed/Added Lines %
Sources/Realtime/RealtimeJoinConfig.swift 5 9 55.56%
Totals Coverage Status
Change from base Build 18098073005: -0.03%
Covered Lines: 5593
Relevant Lines: 7191

💛 - Coveralls

@grdsdev grdsdev merged commit 8083464 into main Sep 30, 2025
22 checks passed
@grdsdev grdsdev deleted the feat/broadcast-replay-support branch September 30, 2025 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants