Class FlexibleSyncConfiguration
A FlexibleSyncConfiguration is used to setup a Realm whose data can be synchronized between devices using Atlas Device Sync. Unlike PartitionSyncConfiguration, a Realm opened with FlexibleSyncConfiguration will be initially empty until one or more subscriptions are added via Subscriptions.
Inherited Members
Namespace: Realms.Sync
Assembly: Realm.dll
Syntax
public class FlexibleSyncConfiguration : SyncConfigurationBase
Constructors
| Edit this page View SourceFlexibleSyncConfiguration(User, string?)
Initializes a new instance of the FlexibleSyncConfiguration class.
Declaration
public FlexibleSyncConfiguration(User user, string? optionalPath = null)
Parameters
Type | Name | Description |
---|---|---|
User | user | A valid User. |
string | optionalPath | Path to the realm, must be a valid full path for the current platform, relative subdirectory, or just filename. |
Properties
| Edit this page View SourcePopulateInitialSubscriptions
Gets or sets a callback that will be invoked the first time a Realm is opened.
Declaration
public FlexibleSyncConfiguration.InitialSubscriptionsDelegate? PopulateInitialSubscriptions { get; set; }
Property Value
Type | Description |
---|---|
FlexibleSyncConfiguration.InitialSubscriptionsDelegate | The FlexibleSyncConfiguration.InitialSubscriptionsDelegate that will be invoked the first time a Realm is opened. |
Remarks
This callback allows you to populate an initial set of subscriptions, which will
then be awaited when GetInstance(RealmConfigurationBase?) is invoked.
The SubscriptionSet returned by Subscriptions is already
called in an Update(Action) block, so there's no need
to start one inside the callback.
Examples
var config = new FlexibleSyncConfiguration(user)
{
PopulateInitialSubscriptions = (realm) =>
{
var myNotes = realm.All<Note>().Where(n => n.AuthorId == myUserId);
realm.Subscriptions.Add(myNotes);
}
};
// The task will complete when all the user notes have been downloaded.
var realm = await Realm.GetInstanceAsync(config);