Skip to content

Commit 521c24f

Browse files
m-hulbertVeskeR
authored andcommitted
Update JS API refs from callbacks to promises
1 parent 814bd6f commit 521c24f

File tree

13 files changed

+411
-260
lines changed

13 files changed

+411
-260
lines changed

content/api/realtime-sdk.textile

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ title: Constructor
33
meta_description: "Realtime Client Library SDK API reference section for the constructor object."
44
meta_keywords: "Ably, Ably realtime, API Reference, Realtime SDK, constructor, instantiate"
55
section: api
6-
index: 1
76
languages:
87
- javascript
98
- nodejs
@@ -13,37 +12,12 @@ languages:
1312
- objc
1413
- csharp
1514
- flutter
16-
jump_to:
17-
Constructor object:
18-
- constructor
19-
Attributes:
20-
- auth
21-
- channels
22-
- client_id#client-id
23-
- connection
24-
- rest_client#rest-client
25-
Methods:
26-
- connect
27-
- close
28-
- stats
29-
- time
30-
- request
31-
Related Types:
32-
- ClientOptions#client-options
33-
- stats#stats-type
34-
- HttpPaginatedResponse#http-paginated-response
3515
redirect_from:
3616
- /docs/api/versions/v1.1/realtime-sdk
3717
- /docs/api/versions/v1.0/realtime-sdk
3818
- /docs/api/versions/v0.8/realtime-sdk
3919
---
4020

41-
blang[javascript,nodejs].
42-
43-
<aside data-type='note'>
44-
<p>This API reference is for version 1.2 of the JavaScript SDK. Version 2.0 references are "available in TypeDoc.":https://ably.com/docs/sdk/js/v2.0/</p>
45-
</aside>
46-
4721
h2(#constructor). Constructor
4822

4923
The Ably Realtime library constructor is overloaded allowing it to be instantiated using a "@ClientOptions@":#client-options object, or more simply using a string containing an "API key":/docs/auth/basic or "Token":/docs/auth/token, as shown below:
@@ -191,6 +165,7 @@ h6(#stats).
191165

192166
bq(definition).
193167
default: stats(Object options, callback("ErrorInfo":/docs/api/realtime-sdk/types#error-info err, "PaginatedResult":/docs/api/realtime-sdk/types#paginated-result<"Stats":#stats> results))
168+
jsall: stats(params?): Promise<"PaginatedResult":/docs/api/realtime-sdk/types#paginated-result<"Stats":#stats>>
194169
ruby: "Deferrable":/docs/api/realtime-sdk/types#deferrable stats(Hash options) -> yields "PaginatedResult":/docs/api/realtime-sdk/types#paginated-result<"Stats":#stats>
195170
java: "PaginatedResult":/docs/api/realtime-sdk/types#paginated-result<"Stats":#stats> stats("Param":#param[] options)
196171
swift,objc: stats(query: ARTStatsQuery?, callback: ("ARTPaginatedResult":/docs/api/realtime-sdk/types#paginated-result<"ARTStats":/docs/api/realtime-sdk/types#stats>?, ARTErrorInfo?) -> Void) throws
@@ -208,14 +183,20 @@ h6(#time).
208183

209184
bq(definition).
210185
default: time(callback("ErrorInfo":/docs/api/realtime-sdk/types#error-info err, Number time))
186+
jsall: time(): Promise<Number>
211187
ruby: "Deferrable":/docs/api/realtime-sdk/types#deferrable time -> yields Time
212188
java: long time()
213189
csharp: Task<DateTimeOffset> TimeAsync()
214190
objc,swift: time(callback: (NSDate?, NSError?) -> Void)
215191

216192
Obtains the time from the Ably service as <span lang="ruby">a @Time@ object</span><span lang="csharp">a @DateTimeOffset@ object</span><span lang="default">milliseconds since epoch</span>. (Clients that do not have access to a sufficiently well maintained time source and wish to issue Ably "TokenRequests":/docs/api/realtime-sdk/authentication#token-request with a more accurate timestamp should use the @queryTime@ "clientOptions":#client-options instead of this method).
217193

218-
blang[jsall,objc,swift].
194+
blang[jsall].
195+
h4. Returns
196+
197+
Returns a promise. On success, the promise is fulfilled with the time as milliseconds since the Unix epoch. On failure, the promise is rejected with an "@ErrorInfo@":/api/realtime-sdk/types#error-info object.
198+
199+
blang[objc,swift].
219200
h4. Callback result
220201

221202
On success, @time@ is a number containing the number of milliseconds since the epoch.
@@ -238,7 +219,6 @@ blang[csharp].
238219

239220
Failure to retrieve the Ably server time will raise an "@AblyException@":#ably-exception.
240221

241-
242222
blang[ruby].
243223
h4. Returns
244224

@@ -250,6 +230,45 @@ blang[ruby].
250230

251231
<%= partial partial_version('rest/_request') %>
252232

233+
blang[javascript].
234+
h6(#batchPublish). batchPublish
235+
236+
There are two overloaded versions of this method:
237+
238+
bq(definition#batchPublish).
239+
default: batchPublish(spec): Promise<BatchResult<BatchPublishSuccessResult | BatchPublishFailureResult>>
240+
241+
Publishes a "@BatchPublishSpec@":LINK object to one or more channels, up to a maximum of 100 channels.
242+
243+
bq(definition#batchPublishArray).
244+
default: batchPublish(specs): Promise<BatchResult<BatchPublishSuccessResult | BatchPublishFailureResult>[]>
245+
246+
Publishes one or more "@BatchPublishSpec@":LINK objects to one or more channels, up to a maximum of 100 channels.
247+
248+
h4. Parameters
249+
250+
- spec := an object describing the messages to be batch published and to which channels<br>__Type: "@BatchPublishSpec@":LINK__
251+
- specs := an array of objects describing the messages to be batch published and to which channels<br>__Type: "@BatchPublishSpec@[]":LINK__
252+
253+
h4. Returns
254+
255+
Returns a promise. On success, the promise is fulfilled with a "@BatchResult@":/LINK object, or an array of @BatchResult@ objects, containing information about the result of the batch publish operation for each channel. The successful results of specific channels are returned as "@BatchPublishSuccessResult@":/LINK objects, whilst failures are "@BatchPublishFailureResult@":/LINK objects. If an array of @BatchResult@ objects are returned, they are in the same order as the provided "@BatchPublishSpec@":/LINK. On failure, the promise is rejected with an "@ErrorInfo@":/api/realtime-sdk/types#error-info object.
256+
257+
h6(#batchPresence). batchPresence
258+
259+
bq(definition#batchPresence).
260+
default: batchPresence(channels): Promise<BatchResult<BatchPresenceSuccessResult | BatchPresenceFailureResult>[]>
261+
262+
Retrieves the presence state for one or more channels, up to a maximum of 100 channels. Presence state includes the "@clientId@":#client-options of members and their current "@PresenceAction@":/api/realtime-sdk/presence#presence-action
263+
264+
h4. Parameters
265+
266+
- channels := an array of one or more channel names, up to a maximum of 100 channels<br>__Type: @String[]@__
267+
268+
h4. Returns
269+
270+
Returns a promise. On success, the promise is fulfilled with a "@BatchResult@":/LINK object containing information about the result of the batch presence request for each channel. The successful results of specific channels are returned as "@BatchPresenceSuccessResult@":/LINK objects, whilst failures are "@BatchPresenceFailureResult@":/LINK objects. On failure, the promise is rejected with an "@ErrorInfo@":/api/realtime-sdk/types#error-info object.
271+
253272
h2(#related-types). Related types
254273

255274
h3(#client-options).

content/api/realtime-sdk/channel-metadata.textile

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,11 @@ title: Channel Metadata
33
meta_description: "Realtime Client Library SDK API reference section for channel metadata."
44
meta_keywords: "Ably, Ably realtime, API Reference, Realtime SDK, channel, metadata, channel metadata, occupancy"
55
section: api
6-
index: 25
7-
jump_to:
8-
Channel API Types:
9-
- ChannelDetails#channel-details
10-
- ChannelStatus#channel-status
11-
- Occupancy#occupancy
126
redirect_from:
137
- /docs/api/versions/v1.1/realtime-sdk/channel-metadata
148
- /docs/api/versions/v1.0/realtime-sdk/channel-metadata
159
---
1610

17-
blang[javascript,nodejs].
18-
19-
<aside data-type='note'>
20-
<p>This API reference is for version 1.2 of the JavaScript SDK. Version 2.0 references are "available in TypeDoc.":https://ably.com/docs/sdk/js/v2.0/</p>
21-
</aside>
22-
2311
h2(#types). Types
2412

2513
The payload of metadata events for channels is the "@ChannelDetails@":#channel-details type which contains the @channelId@ and other static information about the channel, plus a @status@ containing a "@ChannelStatus@":#channel-status instance which contains information about the current state of the channel.

0 commit comments

Comments
 (0)