Skip to content

Commit

Permalink
Allow 'null' as arg to reset the URL.
Browse files Browse the repository at this point in the history
  • Loading branch information
elle-j committed May 1, 2024
1 parent df5e30f commit d83226d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/realm/src/experimental/base-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,24 @@ declare module "../app-services/App" {
interface App {
/**
* Get the current base URL used for sending requests to Atlas App Services.
* If an {@link App.updateBaseUrl | updateBaseUrl } operation is currently in
*
* If an {@link App.updateBaseUrl | updateBaseUrl} operation is currently in
* progress, this value will not be updated with the new value until that
* operation has completed.
* @experimental This feature is experimental and may be changed or removed.
*/
get baseUrl(): string;

/**
* Update the base URL used for sending requests to Atlas App Services.
* Update the base URL used for sending requests to Atlas App Services. If this is
* set to an empty string or `null`, it will reset the base URL to the default one.
*
* If this operation fails, the app will continue to use the original base URL.
* If another {@link App} operation is started while this function is in progress,
* that request will use the original base URL location information.
* @experimental This feature is experimental and may be changed or removed.
*/
updateBaseUrl(newUrl: string): Promise<void>;
updateBaseUrl(newUrl: string | null): Promise<void>;
}
}

Expand All @@ -49,6 +52,6 @@ Object.defineProperty(App.prototype, "baseUrl", {
},
});

App.prototype.updateBaseUrl = function (this: App, newUrl: string) {
return this.internal.updateBaseUrl(newUrl);
App.prototype.updateBaseUrl = function (this: App, newUrl: string | null) {
return this.internal.updateBaseUrl(newUrl ?? undefined);
};

0 comments on commit d83226d

Please sign in to comment.