Skip to content

Commit

Permalink
Update with baseUrl info
Browse files Browse the repository at this point in the history
  • Loading branch information
cbullinger committed Feb 7, 2024
1 parent 8c4b32a commit 84c0fee
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
29 changes: 23 additions & 6 deletions examples/dart/test/app_services_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import "dart:io";
import "dart:convert";
import "dart:isolate";


void main() {
const APP_ID = "example-testers-kvjdy";

Expand All @@ -30,6 +29,24 @@ void main() {
expect(appConfig.defaultRequestTimeout, Duration(seconds: 120));
});

test('BaseUrl not cached on App config', () {
final newUrl = Uri.parse('https://dart.dev');

// Instantiate App with default BaseUrl
final appConfig = AppConfiguration(APP_ID,
defaultRequestTimeout: const Duration(seconds: 120)
);
var app = App(appConfig);
expect(app.baseUrl.toString(), 'https://realm.mongodb.com');

// Update with new BaseUrl
final newConfig = AppConfiguration(APP_ID,
defaultRequestTimeout: const Duration(seconds: 120),
baseUrl:newUrl);
app = App(newConfig);
expect(app.baseUrl.toString(), 'https://dart.dev');
});

test('Access App on background isolate by id', () async {
// :snippet-start: access-app-by-id
// Create an App instance once on main isolate,
Expand All @@ -53,7 +70,7 @@ void main() {
try {
final backgroundApp = App.getById(appId); // :emphasize:

// ... Access App users
// ... Access App users
final user = backgroundApp?.currentUser!;
expect(user, isNotNull); // :remove:

Expand All @@ -68,11 +85,11 @@ void main() {

receivePort.listen((message) {
expect(message, equals('Background task completed'));
receivePort.close();
receivePort.close();
});
if (app.currentUser != null) {
app.deleteUser(anonUser);
}
if (app.currentUser != null) {
app.deleteUser(anonUser);
}
});

test("Custom SSL Certificate", () async {
Expand Down
21 changes: 19 additions & 2 deletions source/sdk/flutter/app-services/connect-to-app.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,21 @@ information.
.. literalinclude:: /examples/generated/flutter/app_services_test.snippet.access-app-client.dart
:language: dart

.. include:: /includes/multiple-app-client-details-and-app-config-cache.rst
You can create multiple App client instances to connect to multiple
Apps. All App client instances that share the same App ID use the same
underlying connection.

.. important:: Changing an App Config After Initializing the App

When you initialize the App client, the configuration is cached internally.
Attempting to "close" and then re-open an App with a changed configuration
within the same process has no effect. The client continues to use the
cached configuration.

In Flutter SDK version 1.9.0 and later, the :flutter-sdk:`baseUrl <realm/AppConfiguration/baseUrl.html>`
configuration property is *not* cached in the App configuration. This
means that you can change the ``baseUrl`` at runtime, and the App client will use the updated configuration. In earlier SDK versions, changes to the ``baseUrl`` in a cached App configuration have no
effect.

.. _flutter-app-client-configuration:

Expand All @@ -66,14 +80,17 @@ Advanced Configuration
.. deprecated:: 1.6.0
``App.localAppName`` and ``App.localAppVersion`` are no longer used.

.. versionchanged:: 1.9.0
``baseUrl`` is no longer cached in the ``AppConfiguration``.

You can add optional arguments to the ``AppConfiguration`` for more granular control
of your ``App`` client. You may want to add things like custom timeouts
for connections or keys for local metadata encryption.
To learn about the available configuration options, refer to the
:flutter-sdk:`AppConfiguration <realm/AppConfiguration-class.html>` reference documentation.

.. literalinclude:: /examples/generated/flutter/app_services_test.snippet.app-client-advanced-configuration.dart
:language: dart
:language: dart

.. note:: Connect Using Android 7 or Older

Expand Down

0 comments on commit 84c0fee

Please sign in to comment.