Skip to content

Commit

Permalink
fix: change name of endBatch to stopBatch
Browse files Browse the repository at this point in the history
  • Loading branch information
BelfordZ committed Jul 25, 2019
1 parent 55bfa71 commit 60c48ca
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/RequestManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe("client-js", () => {
const transport = new EventEmitterTransport("foo://unique-uri");
const c = new RequestManager([transport]);
return c.connect().then(() => {
expect(() => c.endBatch()).toThrow();
expect(() => c.stopBatch()).toThrow();
});
});

Expand Down Expand Up @@ -86,7 +86,7 @@ describe("client-js", () => {
},
});
expect(requests[1]).resolves.toEqual("bar");
c.endBatch();
c.stopBatch();
c.close();
});

Expand Down Expand Up @@ -115,7 +115,7 @@ describe("client-js", () => {
c.request("foo", []),
c.request("foo", []),
];
c.endBatch();
c.stopBatch();
const [a, b] = await Promise.all(requests);
expect(a).toEqual("foo");
expect(b).toEqual("bar");
Expand Down
2 changes: 1 addition & 1 deletion src/RequestManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class RequestManager {
this.batchStarted = true;
}

public endBatch(): void {
public stopBatch(): void {
if (this.batchStarted === false) {
throw new Error("cannot end that which has never started");
}
Expand Down
20 changes: 10 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,34 @@ class Client implements IClient {
/**
* Initiates [[RequestManager.startBatch]] in order to build a batch call.
*
* Subsequent calls to [[Client.request]] will be added to the batch. Once endBatch is called, the promises for the
* [[Client.request]] will then be resolved. If the request manager already has a batch in progress, this method
* is a noop.
* Subsequent calls to [[Client.request]] will be added to the batch. Once [[Client.stopBatch]] is called, the
* promises for the [[Client.request]] will then be resolved. If the [[RequestManager]] already has a batch in
* progress, this method is a noop.
*
* @example
* myClient.startBatch();
* myClient.request("foo", ["bar"]).then(() => console.log('foobar'));
* myClient.request("foo", ["baz"]).then(() => console.log('foobaz'));
* myClient.endBatch();
* myClient.stopBatch();
*/
public startBatch(): void {
return this.requestManager.startBatch();
}

/**
* Initiates [[RequestManager.endBatch]] in order to finalize and send the batch to the underlying transport.
* Initiates [[RequestManager.stopBatch]] in order to finalize and send the batch to the underlying transport.
*
* [[Client.endBatch]] will send the [[Client.request]] calls made since the last [[Client.startBatch]] call. For that
* reason, [[Client.startBatch]] MUST be called before [[Client.endBatch]].
* [[Client.stopBatch]] will send the [[Client.request]] calls made since the last [[Client.startBatch]] call. For
* that reason, [[Client.startBatch]] MUST be called before [[Client.stopBatch]].
*
* @example
* myClient.startBatch();
* myClient.request("foo", ["bar"]).then(() => console.log('foobar'));
* myClient.request("foo", ["baz"]).then(() => console.log('foobaz'));
* myClient.endBatch();
* myClient.stopBatch();
*/
public endBatch(): void {
return this.requestManager.endBatch();
public stopBatch(): void {
return this.requestManager.stopBatch();
}

/**
Expand Down

0 comments on commit 60c48ca

Please sign in to comment.