Add onAttach callback variants to annotations subscribe#2199
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
Disabled knowledge base sources:
WalkthroughAdds optional attach-callback variants to annotation subscription APIs, routes them through internal subscription methods, and ensures provided onAttach callbacks are dispatched asynchronously on the user queue. Proxy and header declarations updated; tests added (duplicated in file). Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant ARTRealtimeAnnotations
participant ARTRealtimeAnnotationsInternal
participant UserQueue
Caller->>ARTRealtimeAnnotations: subscribeWithAttachCallback(onAttach, callback)
ARTRealtimeAnnotations->>ARTRealtimeAnnotationsInternal: subscribe...onAttach...(onAttach, callback)
alt onAttach provided
ARTRealtimeAnnotationsInternal->>UserQueue: dispatch async wrapper for onAttach
UserQueue-->>ARTRealtimeAnnotationsInternal: wrapped onAttach calls original onAttach
end
ARTRealtimeAnnotationsInternal->>ARTRealtimeAnnotations: return ARTEventListener
ARTRealtimeAnnotations-->>Caller: ARTEventListener
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
Test/AblyTests/Tests/RealtimeAnnotationsTests.swift (1)
277-282: Prefer deterministic assertions over fixed delays in negative-callback tests.
delay(1)can introduce CI flakiness; inverted expectations (or equivalent) will make these checks more stable.Also applies to: 324-329
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Test/AblyTests/Tests/RealtimeAnnotationsTests.swift` around lines 277 - 282, Replace the non-deterministic delay(1) inside the waitUntil block with a deterministic Nimble eventual/inverted expectation: instead of using delay to wait, assert channel.state reaches ARTRealtimeChannelState.initialized with expect(channel.state).toEventually(equal(ARTRealtimeChannelState.initialized), timeout: testTimeout) (or use an inverted eventual expectation if testing a negative callback), and remove the delay/done pairing; apply the same change for the other occurrence that asserts channel.state in this file.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@Test/AblyTests/Tests/RealtimeAnnotationsTests.swift`:
- Around line 277-282: Replace the non-deterministic delay(1) inside the
waitUntil block with a deterministic Nimble eventual/inverted expectation:
instead of using delay to wait, assert channel.state reaches
ARTRealtimeChannelState.initialized with
expect(channel.state).toEventually(equal(ARTRealtimeChannelState.initialized),
timeout: testTimeout) (or use an inverted eventual expectation if testing a
negative callback), and remove the delay/done pairing; apply the same change for
the other occurrence that asserts channel.state in this file.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5dc2920b-608f-48e0-88f3-a7390409c521
📒 Files selected for processing (4)
Source/ARTRealtimeAnnotations.mSource/ARTWrapperSDKProxyRealtimeAnnotations.mSource/include/Ably/ARTRealtimeAnnotations.hTest/AblyTests/Tests/RealtimeAnnotationsTests.swift
maratal
left a comment
There was a problem hiding this comment.
LGTM (two small formatting issues)
Mistake in d7c8b45.
Commit d7c8b45 introduced RealtimeAnnotations#subscribe but omitted the onAttach callback variants that RealtimeChannel#subscribe provides. Per RTAN4d, annotations subscribe must have the same return value and callback semantics as channel subscribe (RTL7g), which includes the optional attach callback. This adds subscribeWithAttachCallback:callback: and subscribe:onAttach:callback: to ARTRealtimeAnnotations, mirroring the existing channel API. The internal _subscribe:onAttach:callback: method already accepted an onAttach parameter but the public API was not wiring it through. Also fixes a pre-existing bug in _subscribe:onAttach:callback: where the onAttach callback was not being wrapped to dispatch to the user queue, unlike the channel's equivalent. The channel wraps onAttach to dispatch to the user queue so that it is called on the correct queue per the public API contract. Tests are copied from the RTL7g/RTL7h channel subscribe tests in RealtimeClientChannelTests.swift, adapted to use annotations subscribe. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6ee0b84 to
5ca4c4a
Compare
Commit d7c8b45 introduced
RealtimeAnnotations#subscribebut omitted theonAttachcallback variants thatRealtimeChannel#subscribeprovides. Per RTAN4d, annotations subscribe must have the same return value and callback semantics as channel subscribe (RTL7g), which includes the optional attach callback.This adds
subscribeWithAttachCallback:callback:andsubscribe:onAttach:callback:toARTRealtimeAnnotations, mirroring the existing channel API. The internal_subscribe:onAttach:callback:method already accepted anonAttachparameter but the public API was not wiring it through.Also fixes a pre-existing bug in
_subscribe:onAttach:callback:where theonAttachcallback was not being wrapped to dispatch to the user queue, unlike the channel's equivalent. The channel wrapsonAttachto dispatch to the user queue so that it is called on the correct queue per the public API contract.Tests are copied from the RTL7g/RTL7h channel subscribe tests in
RealtimeClientChannelTests.swift, adapted to use annotations subscribe.Summary by CodeRabbit
New Features
Tests