Search Results for

    Show / Hide Table of Contents

    Class SubscriptionSet

    A collection representing the set of active subscriptions for a Realm instance. This is used in combination with FlexibleSyncConfiguration to declare the set of queries you want to synchronize with the server. You can access and read the subscription set freely, but mutating it must happen in an Update(Action) block.

    Inheritance
    Object
    SubscriptionSet
    Implements
    IReadOnlyList<Subscription>
    IReadOnlyCollection<Subscription>
    IEnumerable<Subscription>
    IEnumerable
    Namespace: Realms.Sync
    Assembly: Realm.dll
    Syntax
    public class SubscriptionSet : IReadOnlyList<Subscription>, IReadOnlyCollection<Subscription>, IEnumerable<Subscription>, IEnumerable
    Remarks

    Any changes to the subscription set will be persisted locally and be available the next time the application starts up - i.e. it's not necessary to subscribe for the same query every time. Updating the subscription set can be done while offline, and only the latest update will be sent to the server whenever connectivity is restored.
    It is strongly recommended that you batch updates as much as possible and request the dataset your application needs upfront. Updating the set of active subscriptions for a Realm is an expensive operation serverside, even if there's very little data that needs downloading.

    Properties

    | Improve this Doc View Source

    Count

    Gets the number of elements in the collection.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    Int32

    The number of elements in the collection.

    | Improve this Doc View Source

    Error

    Gets the error associated with this subscription set, if any. This will only be non-null if State is Error.

    Declaration
    public Exception Error { get; }
    Property Value
    Type Description
    Exception

    The Exception that provides more details for why the subscription set was rejected by the server.

    | Improve this Doc View Source

    Item[Int32]

    Gets the Subscription at the specified index in the set.

    Declaration
    public Subscription this[int index] { get; }
    Parameters
    Type Name Description
    Int32 index

    The zero-based index of the element to get.

    Property Value
    Type Description
    Subscription

    The Subscription at the specified index in the set.

    | Improve this Doc View Source

    State

    Gets the state of the subscription set.

    Declaration
    public SubscriptionSetState State { get; }
    Property Value
    Type Description
    SubscriptionSetState

    The subscription set's state.

    Methods

    | Improve this Doc View Source

    Add<T>(IQueryable<T>, SubscriptionOptions)

    Adds a query to the set of active subscriptions. The query will be joined via an OR statement with any existing queries for the same type.

    Declaration
    public Subscription Add<T>(IQueryable<T> query, SubscriptionOptions options = null)
        where T : RealmObject
    Parameters
    Type Name Description
    IQueryable<T> query

    The query that will be matched on the server.

    SubscriptionOptions options

    The subscription options controlling the name and/or the type of insert that will be performed.

    Returns
    Type Description
    Subscription

    The subscription that represents the specified query.

    Type Parameters
    Name Description
    T

    The type of objects in the query results.

    Remarks

    Adding a query that already exists is a no-op and the existing subscription will be returned.

    | Improve this Doc View Source

    Find(String)

    Finds a subscription by name.

    Declaration
    public Subscription Find(string name)
    Parameters
    Type Name Description
    String name

    The name of the subscription.

    Returns
    Type Description
    Subscription

    A Subscription instance where Name is equal to name if the subscription set contains a subscription with the provided name; null otherwise.

    | Improve this Doc View Source

    Find<T>(IQueryable<T>)

    Finds a subscription by query.

    Declaration
    public Subscription Find<T>(IQueryable<T> query)
        where T : RealmObject
    Parameters
    Type Name Description
    IQueryable<T> query

    The query describing the subscription.

    Returns
    Type Description
    Subscription

    A Subscription instance where Query matches the provided query; null if the subscription set doesn't contain a match.

    Type Parameters
    Name Description
    T

    The type of objects in the query.

    | Improve this Doc View Source

    Remove(Subscription)

    Removes the provided subscription from this subscription set.

    Declaration
    public bool Remove(Subscription subscription)
    Parameters
    Type Name Description
    Subscription subscription

    The subcription to remove.

    Returns
    Type Description
    Boolean

    true if the subscription existed in this subscription set and was removed; false otherwise.

    | Improve this Doc View Source

    Remove(String)

    Removes a subscription with the specified name.

    Declaration
    public bool Remove(string name)
    Parameters
    Type Name Description
    String name

    The name of the subscription to remove.

    Returns
    Type Description
    Boolean

    true if the subscription existed in this subscription set and was removed; false otherwise.

    | Improve this Doc View Source

    Remove<T>(IQueryable<T>, Boolean)

    Removes a subscription with the specified query.

    Declaration
    public int Remove<T>(IQueryable<T> query, bool removeNamed = false)
        where T : RealmObject
    Parameters
    Type Name Description
    IQueryable<T> query

    The query whose matching subscription should be removed.

    Boolean removeNamed

    A flag indicating whether to also remove named subscriptions. Default is false.

    Returns
    Type Description
    Int32

    true if the subscription existed in this subscription set and was removed; false otherwise.

    Type Parameters
    Name Description
    T

    The type of objects in the query results.

    | Improve this Doc View Source

    RemoveAll(Boolean)

    Removes all subscriptions from this subscription set.

    Declaration
    public int RemoveAll(bool removeNamed = false)
    Parameters
    Type Name Description
    Boolean removeNamed

    A flag indicating whether to also remove named subscriptions. Default is false.

    Returns
    Type Description
    Int32

    The number of subscriptions that existed in the set and were removed.

    | Improve this Doc View Source

    RemoveAll(String, Boolean)

    Removes all subscriptions for the provided className.

    Declaration
    public int RemoveAll(string className, bool removeNamed = false)
    Parameters
    Type Name Description
    String className

    The name of the type whose subscriptions are to be removed.

    Boolean removeNamed

    A flag indicating whether to also remove named subscriptions. Default is false.

    Returns
    Type Description
    Int32

    The number of subscriptions that existed for this type and were removed.

    | Improve this Doc View Source

    RemoveAll<T>(Boolean)

    Removes all subscriptions for a specified type.

    Declaration
    public int RemoveAll<T>(bool removeNamed = false)
        where T : RealmObject
    Parameters
    Type Name Description
    Boolean removeNamed

    A flag indicating whether to also remove named subscriptions. Default is false.

    Returns
    Type Description
    Int32

    The number of subscriptions that existed for this type and were removed.

    Type Parameters
    Name Description
    T

    The type of objects whose subscriptions should be removed.

    | Improve this Doc View Source

    Update(Action)

    Update the subscription set and send the request to the server in the background.

    Declaration
    public void Update(Action action)
    Parameters
    Type Name Description
    Action action

    Action to execute, adding or removing subscriptions to this set.

    Remarks

    Calling Update(Action) is a prerequisite for mutating the subscription set - e.g. by calling Add<T>(IQueryable<T>, SubscriptionOptions), Remove(Subscription), or RemoveAll(Boolean).
    Calling this may update the content of this SubscriptionSet - e.g. if another Update(Action) was called on a background thread or if the State changed.
    If you want to wait for the server to acknowledge and send back the data that matches the updated subscriptions, use WaitForSynchronizationAsync().

    | Improve this Doc View Source

    WaitForSynchronizationAsync()

    Waits for the server to acknowledge the subscription set and return the matching objects.

    Declaration
    public Task WaitForSynchronizationAsync()
    Returns
    Type Description
    Task

    An awaitable task, whose successful completion indicates that the server has processed the subscription change and has sent all the data that matches the new subscriptions.

    Remarks

    If the State of the subscription set is Complete the returned Task will complete immediately. If the State is Error, the returned task will be immediately rejected with an error.
    If the change results in removing objects from the Realm - e.g. because subscriptions have been removed, then those objects will have been removed prior to the returned task completing.

    Implements

    System.Collections.Generic.IReadOnlyList<T>
    System.Collections.Generic.IReadOnlyCollection<T>
    System.Collections.Generic.IEnumerable<T>
    System.Collections.IEnumerable
    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2020 Realm
    Generated by DocFX