add

abstract fun <T : RealmObject> add(query: RealmQuery<T>, name: String? = null, updateExisting: Boolean = false): Subscription

Adds a new subscription to the subscription set. If an existing subscription exists that matches the query and the name, this operation does nothing and the existing subscription will be returned.

If an existing named subscription exists on a different query an IllegalArgumentException will be thrown unless updateExisting is set to true, in which case the existing subscription will be updated with the new query.

Return

the newly added subscription.

Parameters

query

the query that will be subscribed to. Note, subscription queries have restrictions compared to normal queries.

name

the name of the subscription. If no name is provided, the subscription is considered to be anonymous.

updateExisting

determines the behaviour if an existing named subscription already exists. This does nothing for anonymous subscriptions.

Throws

if a subscription matching the provided one already exists but on a different query and updateExisting was set to false.