forked from mongodb/docs-realm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(DOCSP-31727): Java SDK Migrate PBS to FS Updates (mongodb#2921)
## Pull Request Info ### Jira - https://jira.mongodb.org/browse/DOCSP-31727 ### Staged Changes - [Sync Data](https://docs-mongodbcom-staging.corp.mongodb.com/realm/docsworker-xlarge/DOCSP-31727/sdk/java/sync/): Remove PBS mentions - [Partition-Based Sync](https://docs-mongodbcom-staging.corp.mongodb.com/realm/docsworker-xlarge/DOCSP-31727/sdk/java/sync/partition-based-sync/): New page with moved PBS info and PBS to FS migration info - [Configure & Open a Synced Realm](https://docs-mongodbcom-staging.corp.mongodb.com/realm/docsworker-xlarge/DOCSP-31727/sdk/java/sync/configure-and-open-a-synced-realm/): Remove PBS info, update the "Synchronous Reads & Writes on the UI Thread" `Important` callout to show FS code examples ### Reminder Checklist If your PR modifies the docs, you might need to also update some corresponding pages. Check if completed or N/A. - [x] Create Jira ticket for corresponding docs-app-services update(s), if any - [x] Checked/updated Admin API - [x] Checked/updated CLI reference ### Review Guidelines [REVIEWING.md](https://github.com/mongodb/docs-realm/blob/master/REVIEWING.md)
- Loading branch information
Showing
9 changed files
with
393 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
.../examples/generated/java/sync/FlexibleSyncTest.snippet.fs-allow-queries-on-ui-thread.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
SyncConfiguration config = new SyncConfiguration.Builder(app.currentUser()) | ||
.allowQueriesOnUiThread(true) | ||
.allowWritesOnUiThread(true) | ||
.initialSubscriptions(new SyncConfiguration.InitialFlexibleSyncSubscriptions() { | ||
@Override | ||
public void configure(Realm realm, MutableSubscriptionSet subscriptions) { | ||
subscriptions.add(Subscription.create("springPeepers", | ||
realm.where(Frog.class) | ||
.equalTo("species", "spring peeper"))); | ||
} | ||
}) | ||
.build(); | ||
|
||
Realm.getInstanceAsync(config, new Realm.Callback() { | ||
@Override | ||
public void onSuccess(Realm realm) { | ||
Log.v( | ||
"EXAMPLE", | ||
"Successfully opened a realm with reads and writes allowed on the UI thread."); | ||
} | ||
}); |
22 changes: 22 additions & 0 deletions
22
...ce/examples/generated/java/sync/FlexibleSyncTest.snippet.fs-allow-queries-on-ui-thread.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
val config = SyncConfiguration.Builder(app.currentUser()) | ||
.allowQueriesOnUiThread(true) | ||
.allowWritesOnUiThread(true) | ||
.initialSubscriptions { realm, subscriptions -> | ||
subscriptions.add( | ||
Subscription.create( | ||
"subscriptionName", | ||
realm.where(Frog::class.java) | ||
.equalTo("species", "springPeepers") | ||
) | ||
) | ||
} | ||
.build() | ||
|
||
Realm.getInstanceAsync(config, object : Realm.Callback() { | ||
override fun onSuccess(realm: Realm) { | ||
Log.v( | ||
"EXAMPLE", | ||
"Successfully opened a realm with reads and writes allowed on the UI thread." | ||
) | ||
} | ||
}) |
35 changes: 35 additions & 0 deletions
35
source/includes/java-synchronous-reads-writes-ui-thread-fs.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.. important:: Synchronous Reads and Writes on the UI Thread | ||
|
||
By default, you can only read or write to a realm in your | ||
application's UI thread using | ||
:ref:`asynchronous transactions <java-async-api>`. That is, | ||
you can only use ``Realm`` methods whose name ends with the word | ||
``Async`` in the main thread of your Android application unless you | ||
explicitly allow the use of synchronous methods. | ||
|
||
This restriction exists for the benefit of your application users: | ||
performing read and write operations on the UI thread can lead to | ||
unresponsive or slow UI interactions, so it's usually best to handle | ||
these operations either asynchronously or in a background thread. | ||
However, if your application requires the use of synchronous | ||
realm reads or writes on the UI thread, you can explicitly allow | ||
the use of synchronous methods with the following | ||
``SyncConfiguration`` options: | ||
|
||
.. tabs-realm-languages:: | ||
|
||
.. tab:: | ||
:tabid: java | ||
|
||
.. literalinclude:: /examples/generated/java/sync/FlexibleSyncTest.snippet.fs-allow-queries-on-ui-thread.java | ||
:language: java | ||
:emphasize-lines: 2,3 | ||
:copyable: false | ||
|
||
.. tab:: | ||
:tabid: kotlin | ||
|
||
.. literalinclude:: /examples/generated/java/sync/FlexibleSyncTest.snippet.fs-allow-queries-on-ui-thread.kt | ||
:language: kotlin | ||
:emphasize-lines: 2,3 | ||
:copyable: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.