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
Makes it so that `RealtimeChannel.attach` exposes the
`ChannelStateChange` via whatever async api (invoke callback or fulfill promise).
This makes it easy for users to access flags on the `ChannelStateChange`
to access information about the attachment.
Copy file name to clipboardExpand all lines: ably.d.ts
+32-20Lines changed: 32 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -2556,9 +2556,9 @@ declare namespace Types {
2556
2556
/**
2557
2557
* Attach to this channel ensuring the channel is created in the Ably system and all messages published on the channel are received by any channel listeners registered using {@link RealtimeChannelCallbacks.subscribe | `subscribe()`}. Any resulting channel state change will be emitted to any listeners registered using the {@link EventEmitter.on | `on()`} or {@link EventEmitter.once | `once()`} methods. As a convenience, `attach()` is called implicitly if {@link RealtimeChannelCallbacks.subscribe | `subscribe()`} for the channel is called, or {@link RealtimePresenceCallbacks.enter | `enter()`} or {@link RealtimePresenceCallbacks.subscribe | `subscribe()`} are called on the {@link RealtimePresenceCallbacks} object for this channel.
2558
2558
*
2559
-
* @param callback - A function which will be called upon completion of the operation. If the operation succeeded, then the function will be called with `null`. If it failed, the function will be called with information about the error.
2559
+
* @param callback - A function which will be called upon completion of the operation. If the operation succeeded and the channel became attached, then the function will be called with a {@link ChannelStateChange} object. If the channel was already attached the function will be called with `null`. If it failed, the function will be called with information about the error.
* Detach from this channel. Any resulting channel state change is emitted to any listeners registered using the {@link EventEmitter.on | `on()`} or {@link EventEmitter.once | `once()`} methods. Once all clients globally have detached from the channel, the channel will be released in the Ably service within two minutes.
2564
2564
*
@@ -2590,32 +2590,44 @@ declare namespace Types {
2590
2590
*
2591
2591
* @param event - The event name.
2592
2592
* @param listener - An event listener function.
2593
-
* @param callbackWhenAttached - A function which will be called upon completion of the channel {@link RealtimeChannelCallbacks.attach | `attach()`} operation. If the operation succeeded, then the function will be called with `null`. If it failed, the function will be called with information about the error.
2593
+
* @param callbackWhenAttached - A function which will be called upon completion of the channel {@link RealtimeChannelCallbacks.attach | `attach()`} operation. If the operation succeeded and the channel became attached, then the function will be called with a {@link ChannelStateChange} object. If the channel was already attached the function will be called with `null`. If it failed, the function will be called with information about the error.
* Registers a listener for messages on this channel for multiple event name values.
2598
2602
*
2599
2603
* @param events - An array of event names.
2600
2604
* @param listener - An event listener function.
2601
-
* @param callbackWhenAttached - A function which will be called upon completion of the channel {@link RealtimeChannelCallbacks.attach | `attach()`} operation. If the operation succeeded, then the function will be called with `null`. If it failed, the function will be called with information about the error.
2605
+
* @param callbackWhenAttached - A function which will be called upon completion of the channel {@link RealtimeChannelCallbacks.attach | `attach()`} operation. If the operation succeeded and the channel became attached, then the function will be called with a {@link ChannelStateChange} object. If the channel was already attached the function will be called with `null`. If it failed, the function will be called with information about the error.
* Registers a listener for messages on this channel that match the supplied filter.
2606
2614
*
2607
2615
* @param filter - A {@link MessageFilter}.
2608
2616
* @param listener - An event listener function.
2609
-
* @param callbackWhenAttached - A function which will be called upon completion of the channel {@link RealtimeChannelCallbacks.attach | `attach()`} operation. If the operation succeeded, then the function will be called with `null`. If it failed, the function will be called with information about the error.
2617
+
* @param callbackWhenAttached - A function which will be called upon completion of the channel {@link RealtimeChannelCallbacks.attach | `attach()`} operation. If the operation succeeded and the channel became attached, then the function will be called with a {@link ChannelStateChange} object. If the channel was already attached the function will be called with `null`. If it failed, the function will be called with information about the error.
* Registers a listener for messages on this channel. The caller supplies a listener function, which is called each time one or more messages arrives on the channel.
2614
2626
*
2615
2627
* @param listener - An event listener function.
2616
-
* @param callbackWhenAttached - A function which will be called upon completion of the channel {@link RealtimeChannelCallbacks.attach | `attach()`} operation. If the operation succeeded, then the function will be called with `null`. If it failed, the function will be called with information about the error.
2628
+
* @param callbackWhenAttached - A function which will be called upon completion of the channel {@link RealtimeChannelCallbacks.attach | `attach()`} operation. If the operation succeeded and the channel became attached, then the function will be called with a {@link ChannelStateChange} object. If the channel was already attached the function will be called with `null`. If it failed, the function will be called with information about the error.
* Publishes a single message to the channel with the given event name and payload. When publish is called with this client library, it won't attempt to implicitly attach to the channel, so long as [transient publishing](https://ably.com/docs/realtime/channels#transient-publish) is available in the library. Otherwise, the client will implicitly attach.
2621
2633
*
@@ -2666,9 +2678,9 @@ declare namespace Types {
2666
2678
/**
2667
2679
* Attach to this channel ensuring the channel is created in the Ably system and all messages published on the channel are received by any channel listeners registered using {@link RealtimeChannelPromise.subscribe | `subscribe()`}. Any resulting channel state change will be emitted to any listeners registered using the {@link EventEmitter.on | `on()`} or {@link EventEmitter.once | `once()`} methods. As a convenience, `attach()` is called implicitly if {@link RealtimeChannelPromise.subscribe | `subscribe()`} for the channel is called, or {@link RealtimePresencePromise.enter | `enter()`} or {@link RealtimePresencePromise.subscribe | `subscribe()`} are called on the {@link RealtimePresencePromise} object for this channel.
2668
2680
*
2669
-
* @returns A promise which resolves upon success of the operation and rejects with an {@linkErrorInfo} object upon its failure.
2681
+
* @returns A promise which, upon success, if the channel became attached will be fulfilled with a {@linkChannelStateChange} object. If the channel was already attached the promise will be fulfilled with `null`. Upon failure, the promise will be rejected with an {@link ErrorInfo} object.
2670
2682
*/
2671
-
attach(): Promise<void>;
2683
+
attach(): Promise<ChannelStateChange|null>;
2672
2684
/**
2673
2685
* Detach from this channel. Any resulting channel state change is emitted to any listeners registered using the {@link EventEmitter.on | `on()`} or {@link EventEmitter.once | `once()`} methods. Once all clients globally have detached from the channel, the channel will be released in the Ably service within two minutes.
2674
2686
*
@@ -2694,32 +2706,32 @@ declare namespace Types {
2694
2706
*
2695
2707
* @param event - The event name.
2696
2708
* @param listener - An event listener function.
2697
-
* @returns A promise which resolves upon success of the channel{@linkRealtimeChannelPromise.attach | `attach()`} operation and rejects with an {@link ErrorInfo} object upon its failure.
2709
+
* @returns A promise which, upon successful attachment to the channel, will be fulfilled with a {@linkChannelStateChange} object. If the channel was already attached the promise will be resolved with `null`. Upon failure, the promise will be rejected with an {@link ErrorInfo} object.
* Registers a listener for messages on this channel for multiple event name values.
2702
2714
*
2703
2715
* @param events - An array of event names.
2704
2716
* @param listener - An event listener function.
2705
-
* @returns A promise which resolves upon success of the channel{@linkRealtimeChannelPromise.attach | `attach()`} operation and rejects with an {@link ErrorInfo} object upon its failure.
2717
+
* @returns A promise which, upon successful attachment to the channel, will be fulfilled with a {@linkChannelStateChange} object. If the channel was already attached the promise will be resolved with `null`. Upon failure, the promise will be rejected with an {@link ErrorInfo} object.
* Registers a listener for messages on this channel that match the supplied filter.
2710
2722
*
2711
2723
* @param filter - A {@link MessageFilter}.
2712
2724
* @param listener - An event listener function.
2713
-
* @returns A promise which resolves upon success of the channel{@linkRealtimeChannelPromise.attach | `attach()`} operation and rejects with an {@link ErrorInfo} object upon its failure.
2725
+
* @returns A promise which, upon successful attachment to the channel, will be fulfilled with a {@linkChannelStateChange} object. If the channel was already attached the promise will be resolved with `null`. Upon failure, the promise will be rejected with an {@link ErrorInfo} object.
* Registers a listener for messages on this channel. The caller supplies a listener function, which is called each time one or more messages arrives on the channel.
2718
2730
*
2719
2731
* @param callback - An event listener function.
2720
-
* @returns A promise which resolves upon success of the channel{@linkRealtimeChannelPromise.attach | `attach()`} operation and rejects with an {@link ErrorInfo} object upon its failure.
2732
+
* @returns A promise which, upon successful attachment to the channel, will be fulfilled with a {@linkChannelStateChange} object. If the channel was already attached the promise will be resolved with `null`. Upon failure, the promise will be rejected with an {@link ErrorInfo} object.
* Publishes a single message to the channel with the given event name and payload. When publish is called with this client library, it won't attempt to implicitly attach to the channel, so long as [transient publishing](https://ably.com/docs/realtime/channels#transient-publish) is available in the library. Otherwise, the client will implicitly attach.
0 commit comments