@@ -21,35 +21,51 @@ interface IClient {
21
21
* ```
22
22
*
23
23
*/
24
-
25
24
class Client implements IClient {
26
25
public requestManager : RequestManager ;
27
26
constructor ( requestManager : RequestManager ) {
28
27
this . requestManager = requestManager ;
29
28
}
30
29
31
30
/**
32
- * Starts a JSON-RPC Batch call. The client will batch following requests.
33
- * This method REQUIRES endBatch be called when finished calling requests.
31
+ * Initiates [[RequestManager.startBatch]] in order to build a batch call.
32
+ *
33
+ * Subsequent calls to [[Client.request]] will be added to the batch. Once endBatch is called, the promises for the
34
+ * [[Client.request]] will then be resolved. If the request manager already has a batch in progress, this method
35
+ * is a noop.
36
+ *
37
+ * @example
38
+ * myClient.startBatch();
39
+ * myClient.request("foo", ["bar"]).then(() => console.log('foobar'));
40
+ * myClient.request("foo", ["baz"]).then(() => console.log('foobaz'));
41
+ * myClient.endBatch();
34
42
*/
35
43
public startBatch ( ) : void {
36
44
return this . requestManager . startBatch ( ) ;
37
45
}
38
46
39
47
/**
40
- * Ends a JSON-RPC Batch call. This client will batch requests from when startBatch
41
- * was called until endBatch. This REQUIRES startBatch to be called first.
48
+ * Initiates [[RequestManager.endBatch]] in order to finalize and send the batch to the underlying transport.
49
+ *
50
+ * [[Client.endBatch]] will send the [[Client.request]] calls made since the last [[Client.startBatch]] call. For that
51
+ * reason, [[Client.startBatch]] MUST be called before [[Client.endBatch]].
52
+ *
53
+ * @example
54
+ * myClient.startBatch();
55
+ * myClient.request("foo", ["bar"]).then(() => console.log('foobar'));
56
+ * myClient.request("foo", ["baz"]).then(() => console.log('foobaz'));
57
+ * myClient.endBatch();
42
58
*/
43
59
public endBatch ( ) : void {
44
60
return this . requestManager . endBatch ( ) ;
45
61
}
62
+
46
63
/**
47
64
* A JSON-RPC call is represented by sending a Request object to a Server.
48
65
*
49
- * @param method A String containing the name of the method to be invoked.
50
- * Method names that begin with the word rpc followed by a
51
- * period character (U+002E or ASCII 46) are reserved for rpc-internal
52
- * methods and extensions and MUST NOT be used for anything else.
66
+ * @param method A String containing the name of the method to be invoked. Method names that begin with the word rpc
67
+ * followed by a period character (U+002E or ASCII 46) are reserved for rpc-internal methods and extensions and
68
+ * MUST NOT be used for anything else.
53
69
* @param params A Structured value that holds the parameter values to be used during the invocation of the method.
54
70
*/
55
71
public async request ( method : string , params : any ) {
0 commit comments