-
Notifications
You must be signed in to change notification settings - Fork 584
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
Realm Web: Refresh access token #3020
Changes from all commits
3ec8e0c
da84544
3c45c70
2f20743
4094b1c
0719c04
06fb450
85a7525
9f94646
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright 2020 Realm Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//////////////////////////////////////////////////////////////////////////// | ||
|
||
export type Method = "GET" | "POST" | "DELETE" | "PUT"; | ||
|
||
export type Headers = { [name: string]: string }; | ||
|
||
export interface Request<RequestBody> { | ||
method: Method; | ||
url: string; | ||
timeoutMs?: number; | ||
headers?: Headers; | ||
body?: RequestBody | string; | ||
} | ||
|
||
export interface Response { | ||
statusCode: number; | ||
headers: Headers; | ||
body: string; | ||
} | ||
|
||
export type SuccessCallback = (response: Response) => void; | ||
|
||
export type ErrorCallback = (err: Error) => void; | ||
|
||
export interface ResponseHandler { | ||
onSuccess: SuccessCallback; | ||
onError: ErrorCallback; | ||
} | ||
|
||
export interface NetworkTransport { | ||
fetchAndParse<RequestBody extends any, ResponseBody extends any>( | ||
request: Request<RequestBody>, | ||
): Promise<ResponseBody>; | ||
fetchWithCallbacks<RequestBody extends any>( | ||
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 wondering why fetch with parsing is promise-based, and fetch without parsing (or limited parsing) is callback-based? 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. Because when Realm JS is using this, its easier to consume from JS if a |
||
request: Request<RequestBody>, | ||
handler: ResponseHandler, | ||
): void; | ||
} |
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.
(void comment) Is this actually awaited before thrown? I'm more & more impressed with TS.
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.
Is what awaited? (or is your "void comment" because I forced pushed a change? 😺 )