Skip to content

Commit

Permalink
chore: address feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanZhengYP committed May 29, 2020
1 parent 7e50b36 commit 50bddce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
13 changes: 6 additions & 7 deletions packages/eventstream-serde-browser/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ export function iterableToReadableStream<T>(
): ReadableStream<T> {
const iterator = asyncIterable[Symbol.asyncIterator]();
return new ReadableStream({
pull(constroller) {
return iterator.next().then(({ done, value }) => {
if (done) {
return constroller.close();
}
constroller.enqueue(value);
});
async pull(controller) {
const { done, value } = await iterator.next();
if (done) {
return controller.close();
}
controller.enqueue(value);
}
});
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { HttpHandlerOptions, RequestHandlerMetadata } from "@aws-sdk/types";
import { HttpHandler, HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
import { formatUrl } from "@aws-sdk/util-format-url";
/**
* Base handler for websocket requests. By default, the request input and output
* body will be in a ReadableStream, because of interface consistency among middleware.
* If ReadableStream is not available, like in React-Native, the response body
* will be an async iterable.
*/

export interface WebSocketHandlerOptions {
/**
Expand All @@ -16,6 +10,12 @@ export interface WebSocketHandlerOptions {
connectionTimeout?: number;
}

/**
* Base handler for websocket requests. By default, the request input and output
* body will be in a ReadableStream, because of interface consistency among middleware.
* If ReadableStream is not available, like in React-Native, the response body
* will be an async iterable.
*/
export class WebSocketHandler implements HttpHandler {
public readonly metadata: RequestHandlerMetadata = {
handlerProtocol: "websocket"
Expand Down

0 comments on commit 50bddce

Please sign in to comment.