-
Type: Improvement
-
Resolution: Fixed
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
Goals
A simpler configuration around synchronization modes.
Expected Results
Being able to open a Realm in either "query-based" or "full" mode.
Actual Results
We have two optional boolean configuration properties on the Realm.Sync.Configuration interface:
partial
> Whether this Realm should be opened in 'query-based synchronization' mode. Query-based synchronisation only synchronizes those objects that match the query specified in contrast to the normal mode of operation that synchronises all objects in a remote Realm.
fullSynchronization
> Whether this Realm should be opened in query-based or full synchronization mode. The default is query-based mode which only synchronizes objects that have been subscribed to.
A fully synchronized Realm will synchronize the entire Realm in the background, irrespectively of the data being used or not.
Proposed solution
I propose we deprecate both the partial and fullSynchronization properties in favor of a third new property, called mode, as the two modes are mutually exclusive.
The new mode property should be an optional string-based enum which (defaulting to "query-based"), taking a SyncMode as argument:
/** * The mode of synchronization which a Realm can be opened in. */ enum SyncMode { /** Only synchronizes objects that have been subscribed to */ QueryBased = "query-based", /** Synchronizes the entire Realm, irrespectively of the data being used or not */ Full = "full", }
Users can explicitly open in query-based mode using (which will be default):
TypeScript
const realmConfig = user.createConfiguration({ sync: { mode: SyncMode.QueryBased } }); const realm = new Realm(realmConfig);
JavaScript
const realmConfig = user.createConfiguration({ sync: { mode: "query-based" } }); const realm = new Realm(realmConfig);
Or alternatively the user can open in full mode using:
TypeScript
const realmConfig = user.createConfiguration({ sync: { mode: SyncMode.Full } }); const realm = new Realm(realmConfig);
JavaScript
const realmConfig = user.createConfiguration({ sync: { mode: "full" } }); const realm = new Realm(realmConfig);
Version of Realm and Tooling
- Realm JS SDK Version: 2.25.0
- Node or React Native: N/A
- Client OS & Version: N/A
- Which debugger for React Native: N/A
- is depended on by
-
RJS-305 [10.0] Breaking changes
- Closed