You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Replaces the implementation of ``publish(objectMessages:)``.
12
+
///
13
+
/// Used by integration tests, for example to disable `ObjectMessage` publishing so that a test can verify that a behaviour is not a side effect of an `ObjectMessage` sent by the SDK.
/// Returns the current state of the Realtime channel that this wraps.
12
17
varchannelState:ARTRealtimeChannelState{get}
13
18
}
14
19
15
20
internalfinalclassDefaultCoreSDK:CoreSDK{
21
+
/// Used to synchronize access to internal mutable state.
22
+
privateletmutex=NSLock()
23
+
16
24
privateletchannel:AblyPlugin.RealtimeChannel
17
25
privateletclient:AblyPlugin.RealtimeClient
18
26
privateletpluginAPI:PluginAPIProtocol
19
27
privateletlogger:AblyPlugin.Logger
20
28
29
+
/// If set to true, ``publish(objectMessages:)`` will behave like a no-op.
30
+
///
31
+
/// This enables the `testsOnly_overridePublish(with:)` test hook.
32
+
///
33
+
/// - Note: This should be `throws(InternalError)` but that causes a compilation error of "Runtime support for typed throws function types is only available in macOS 15.0.0 or newer".
/// Replaces the method that this `RealtimeObjects` uses to send any outbound `ObjectMessage`s.
124
+
///
125
+
/// Used by integration tests, for example to disable `ObjectMessage` publishing so that a test can verify that a behaviour is not a side effect of an `ObjectMessage` sent by the SDK.
/// The contract for what this will return are the same as those of `JSONValue.toJSONSerializationInputElemtn`, with one addition: any values in the input of case `.extra` will be passed to the `serializeExtraValue` function, and the result of this function call will be inserted into the output object.
46
+
/// The contract for what this will return are the same as those of `JSONValue.toJSONSerializationInputElement`, with one addition: any values in the input of case `.extra` will be passed to the `serializeExtraValue` function, and the result of this function call will be inserted into the output object.
@@ -39,13 +40,50 @@ final class Subscriber<each CallbackArg: Sendable>: Sendable {
39
40
guardlet self else{
40
41
return
41
42
}
42
-
mutex.withLock{
43
+
letcallListeners=mutex.withLock{
43
44
letinvocation=(repeateach arg)
44
45
invocations.append(invocation)
46
+
47
+
return{[listeners]in
48
+
forlistenerin listeners {
49
+
listener.callAsFunction(repeateach invocation)
50
+
}
51
+
}
45
52
}
46
53
iflet action {
47
54
action(repeateach arg)
48
55
}
56
+
callListeners()
49
57
}
50
58
}
59
+
60
+
/// A wrapper that allows us to store a callback that takes variadic args.
61
+
///
62
+
/// This allows us to avoid the error "Cannot fully abstract a value of variadic function type '@Sendable (repeat each CallbackArg) -> ()' because different contexts will not be able to reliably agree on a calling convention; try wrapping it in a struct" that we get if we try to directly store the callback in an array. Claude suggested this solution.
/// Adds a listener which replays all previously buffered and future invocations of any function previously created by ``createListener(_:)``.
72
+
///
73
+
/// This is useful for the scenario where you want to set up a subscription synchronously (so as not to miss any events) but then in an `async` context perform actions as a result of the invocation of the listener. (You could equally use the SDK's `AsyncSequence` interface but the approach here is a closer mapping of the ported JS integration tests that call `subscribe`.)
0 commit comments