-
Notifications
You must be signed in to change notification settings - Fork 5
React Web: .reactively() returns { response, aborted }
#208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
8a6d1af
c69afe5
0e50e38
5f2340f
528188e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -445,7 +445,7 @@ class _Reactively { | |
| partialRequest?: {{ client.proto.state_name }}.Partial{{ method.proto.name }}Request, | ||
| options?: { signal?: AbortSignal }, | ||
| ): Promise<[ | ||
| AsyncGenerator<{{ client.proto.state_name }}.{{ method.proto.name }}Response, void, unknown>, | ||
| AsyncGenerator<reboot_web.ResponseOrAborted<{{ client.proto.state_name }}.{{ method.proto.name }}Response, {{ client.proto.state_name | to_camel }}{{ method.proto.name | to_camel }}Aborted>, void, unknown>, | ||
| (newRequest: {{ client.proto.state_name }}.Partial{{ method.proto.name }}Request) => void | ||
| ]> { | ||
| const request = {{ client.proto.state_name }}{{ method.proto.name }}RequestToProtobuf(partialRequest); | ||
|
|
@@ -458,9 +458,14 @@ class _Reactively { | |
| id: this.#id, | ||
| requestType: {{ method.input_type }}, | ||
| responseType: {{ method.output_type }}, | ||
| abortedType: {{ client.proto.state_name | to_camel }}{{ method.proto.name | to_camel }}Aborted, | ||
| request: request, | ||
| signal: options?.signal, | ||
| bearerToken: context.bearerToken, | ||
| // Read the token from `context` on every attempt, so that a | ||
| // token set with `context.setBearerToken()` after the read | ||
| // started is sent on the next attempt. | ||
| bearerToken: async () => await context.bearerToken?.(), | ||
| onUnauthenticated: context.onUnauthenticated, | ||
| websockets: context.websockets, | ||
| } | ||
| ); | ||
|
|
@@ -470,10 +475,13 @@ class _Reactively { | |
| setRequest(typedRequest); | ||
| }; | ||
|
|
||
| async function* typedGenerator(): AsyncGenerator<{{ client.proto.state_name }}.{{ method.proto.name }}Response, void, unknown> { | ||
| for await (const response of generator) { | ||
| const typedResponse = {{ client.proto.state_name }}{{ method.proto.name }}ResponseFromProtobufShape(response); | ||
| yield typedResponse; | ||
| async function* typedGenerator(): AsyncGenerator<reboot_web.ResponseOrAborted<{{ client.proto.state_name }}.{{ method.proto.name }}Response, {{ client.proto.state_name | to_camel }}{{ method.proto.name | to_camel }}Aborted>, void, unknown> { | ||
| for await (const { response, aborted } of generator) { | ||
| if (aborted !== undefined) { | ||
| yield { aborted }; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just confirming aborted doesn't need to go through any kind of protobuf shape transformation?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. The response gets converted at the yield but |
||
| continue; | ||
| } | ||
| yield { response: {{ client.proto.state_name }}{{ method.proto.name }}ResponseFromProtobufShape(response) }; | ||
| } | ||
| }; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious for all of the spellings of the aborted types, is there not a
ChatRoom.MessagesAbortedonly aChatRoomMessagesAborted?If only the latter exists then no changes necessary, but if the former exists it would be great to use it everywhere!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only the
ChatRoomMessgesAbortedtype exists in web and React.