Skip to content

Commit dc59db3

Browse files
authored
Merge pull request #2648 from ably/edu-1590-api-js-latest
[EDU-1590] Update JS API references to match latest ably-js v2 API
2 parents 0b31026 + e6fa9f1 commit dc59db3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1747
-871
lines changed

content/api/realtime-sdk.textile

Lines changed: 92 additions & 39 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:
@@ -148,7 +122,7 @@ h6(#connect).
148122
csharp: Connect
149123

150124
bq(definition).
151-
default: connect()
125+
default: connect(): void
152126
ruby: "Deferrable":/docs/api/realtime-sdk/types#deferrable connect -> yields "@Connection@":/docs/api/realtime-sdk/connection
153127
java: void connect()
154128
csharp: void Connect()
@@ -169,7 +143,7 @@ h6(#close).
169143
csharp: Close
170144

171145
bq(definition).
172-
default: close()
146+
default: close(): void
173147
ruby: "Deferrable":/docs/api/realtime-sdk/types#deferrable close -> yields "@Connection@":/docs/api/realtime-sdk/connection
174148
java: void close()
175149
csharp: void Close()
@@ -190,13 +164,14 @@ h6(#stats).
190164
csharp: Stats
191165

192166
bq(definition).
193-
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))
194-
ruby: "Deferrable":/docs/api/realtime-sdk/types#deferrable stats(Hash options) -> yields "PaginatedResult":/docs/api/realtime-sdk/types#paginated-result<"Stats":#stats>
195-
java: "PaginatedResult":/docs/api/realtime-sdk/types#paginated-result<"Stats":#stats> stats("Param":#param[] options)
196-
swift,objc: stats(query: ARTStatsQuery?, callback: ("ARTPaginatedResult":/docs/api/realtime-sdk/types#paginated-result<"ARTStats":/docs/api/realtime-sdk/types#stats>?, ARTErrorInfo?) -> Void) throws
197-
csharp: Task<"PaginatedResult":/docs/api/realtime-sdk/types#paginated-result<"Stats":/docs/api/realtime-sdk/types#stats>> StatsAsync(StatsRequestParams query)
167+
default: stats(Object options, callback("ErrorInfo":/docs/api/realtime-sdk/types#error-info err, "PaginatedResult":/docs/api/realtime-sdk/types#paginated-result<"Stats":#stats-type> results))
168+
jsall: stats(Object params?): Promise<"PaginatedResult":/docs/api/realtime-sdk/types#paginated-result<"Stats":#stats-type>>
169+
ruby: "Deferrable":/docs/api/realtime-sdk/types#deferrable stats(Hash options) -> yields "PaginatedResult":/docs/api/realtime-sdk/types#paginated-result<"Stats":#stats-type>
170+
java: "PaginatedResult":/docs/api/realtime-sdk/types#paginated-result<"Stats":#stats-type> stats("Param":#param[] options)
171+
swift,objc: stats(query: ARTStatsQuery?, callback: ("ARTPaginatedResult":/docs/api/realtime-sdk/types#paginated-result<"ARTStats":#stats-type>?, ARTErrorInfo?) -> Void) throws
172+
csharp: Task<"PaginatedResult":/docs/api/realtime-sdk/types#paginated-result<"Stats":#stats-type>> StatsAsync(StatsRequestParams query)
198173

199-
This call queries the "REST @/stats@ API":/docs/api/rest-api#stats and retrieves your application's usage statistics. A "PaginatedResult":/docs/api/realtime-sdk/types#paginated-result is returned, containing an array of "Stats":#stats for the first page of results. "PaginatedResult":/docs/api/realtime-sdk/types#paginated-result objects are iterable providing a means to page through historical statistics. "See an example set of raw stats returned via the REST API":/docs/metadata-stats/stats#metrics.
174+
This call queries the "REST @/stats@ API":/docs/api/rest-api#stats and retrieves your application's usage statistics. A "PaginatedResult":/docs/api/realtime-sdk/types#paginated-result is returned, containing an array of "Stats":#stats-type for the first page of results. "PaginatedResult":/docs/api/realtime-sdk/types#paginated-result objects are iterable providing a means to page through historical statistics. "See an example set of raw stats returned via the REST API":/docs/metadata-stats/stats#metrics.
200175

201176
See "statistics":/docs/metadata-stats/stats for more information.
202177

@@ -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))
211-
ruby: "Deferrable":/docs/api/realtime-sdk/types#deferrable time -> yields Time
212-
java: long time()
213-
csharp: Task<DateTimeOffset> TimeAsync()
186+
jsall: time(): Promise<Number>
187+
ruby: "Deferrable":/docs/api/realtime-sdk/types#deferrable time -> yields Time
188+
java: long time()
189+
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@":/docs/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("BatchPublishSpec":#batch-publish-spec spec): Promise<"BatchResult":#batch-result<"BatchPublishSuccessResult":#batch-publish-success-result | "BatchPublishFailureResult":#batch-publish-failure-result>>
240+
241+
Publishes a "@BatchPublishSpec@":#batch-publish-spec object to one or more channels, up to a maximum of 100 channels.
242+
243+
bq(definition#batchPublishArray).
244+
default: batchPublish("BatchPublishSpec[]":#batch-publish-spec specs): Promise<"BatchResult":#batch-result<"BatchPublishSuccessResult":#batch-publish-success-result | "BatchPublishFailureResult":#batch-publish-failure-result>[]>
245+
246+
Publishes one or more "@BatchPublishSpec@":#batch-publish-spec 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@":#batch-publish-spec
251+
- specs := an array of objects describing the messages to be batch published and to which channels<br>__Type: "@BatchPublishSpec@[]":#batch-publish-spec
252+
253+
h4. Returns
254+
255+
Returns a promise. On success, the promise is fulfilled with a "@BatchResult@":#batch-result object, or an array of "@BatchResult@":#batch-result objects, containing information about the result of the batch publish operation for each channel. The successful results of specific channels are returned as "@BatchPublishSuccessResult@":#batch-publish-success-result objects, whilst failures are "@BatchPublishFailureResult@":#batch-publish-failure-result objects. If an array of "@BatchResult@":#batch-result objects are returned, they are in the same order as the provided "@BatchPublishSpec@":#batch-publish-spec. On failure, the promise is rejected with an "@ErrorInfo@":/docs/api/realtime-sdk/types#error-info object.
256+
257+
h6(#batchPresence). batchPresence
258+
259+
bq(definition#batchPresence).
260+
default: batchPresence(String[] channels): Promise<"BatchResult":#batch-result<"BatchPresenceSuccessResult":#batch-presence-success-result | "BatchPresenceFailureResult":#batch-presence-failure-result>[]>
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@":/docs/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@":#batch-result object containing information about the result of the batch presence request for each channel. The successful results of specific channels are returned as "@BatchPresenceSuccessResult@":#batch-presence-success-result objects, whilst failures are "@BatchPresenceFailureResult@":#batch-presence-failure-result objects. On failure, the promise is rejected with an "@ErrorInfo@":/docs/api/realtime-sdk/types#error-info object.
271+
253272
h2(#related-types). Related types
254273

255274
h3(#client-options).
@@ -274,6 +293,8 @@ h3(#stats-type).
274293

275294
h3(#stats-granularity).
276295
objc,swift: ARTStatsGranularity
296+
jsall: StatsIntervalGranularity
297+
csharp: StatsIntervalGranularity
277298

278299
<%= partial partial_version('types/_stats_granularity') %>
279300

@@ -287,3 +308,35 @@ h3(#param).
287308

288309
blang[java].
289310
<%= partial partial_version('types/_param'), indent: 2, skip_first_indent: true %>
311+
312+
blang[jsall].
313+
314+
h3(#batch-publish-spec).
315+
jsall: BatchPublishSpec
316+
317+
<%= partial partial_version('types/_batch_publish_spec') %>
318+
319+
h3(#batch-result).
320+
jsall: BatchResult
321+
322+
<%= partial partial_version('types/_batch_result') %>
323+
324+
h3(#batch-publish-success-result).
325+
jsall: BatchPublishSuccessResult
326+
327+
<%= partial partial_version('types/_batch_publish_success_result') %>
328+
329+
h3(#batch-publish-failure-result).
330+
jsall: BatchPublishFailureResult
331+
332+
<%= partial partial_version('types/_batch_publish_failure_result') %>
333+
334+
h3(#batch-presence-success-result).
335+
jsall: BatchPresenceSuccessResult
336+
337+
<%= partial partial_version('types/_batch_presence_success_result') %>
338+
339+
h3(#batch-presence-failure-result).
340+
jsall: BatchPresenceFailureResult
341+
342+
<%= partial partial_version('types/_batch_presence_failure_result') %>

0 commit comments

Comments
 (0)