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.


the newly added subscription.



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


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


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


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