Join us at MongoDB.local London on 7 May to unlock new possibilities for your data. Use WEB50 to save 50%.
Register now >
Docs Menu
Docs Home
/ /
io.realm.mongodb.sync

Interface SubscriptionSet

Implemented interfaces:

  • java.lang.Iterable

A subscription set is an immutable view of all current Subscription s for a given Realm that has been configured for flexible sync.

Flexible Sync is a way of defining which data gets synchronized to and from the device using RealmQuery s. The query and its metadata are represented by a Subscription .

Un conjunto de suscripciones define todos los datos disponibles para el dispositivo y que se sincronizan con el servidor. Si el conjunto de suscripciones detecta un error, por ejemplo, al contener una consulta no válida, todo el conjunto entrará en el estado SubscriptionSet.State.ERROR y no se realizará ninguna sincronización hasta que se corrija el error.

If a subscription is removed, so is the corresponding data, but it is only removed from the device. It isn't deleted on the server.

Es posible modificar un conjunto de suscripciones sin conexión, pero el servidor no acepta la modificación antes de que getState() devuelva SubscriptionSet.State.COMPLETE.

It is possible to force the subscription set to be synchronized with the server by using waitForSynchronization() and its variants.

Modificador y Tipo
Clase y descripción

public static final

public static interface

public static interface

public static interface

Modificador y Tipo
Método y descripción
String name
)

Encuentra la suscripción con un nombre determinado.

Encuentre la primera suscripción que contenga la consulta dada.

public String

If getState() returns State.ERROR , this method will return the reason.

Returns the current state of the SubscriptionSet.

public int

size ()

Returns how many subscriptions are currently in this subscription set.

conjunto de suscripciones públicas

Modify the subscription set.

Modifica de manera asíncrona el conjunto de suscripciones.

public booleano

Wait for the subscription set to synchronize with the server.

public booleano

Wait for the subscription set to synchronize with the server.

Asynchronously wait for the subscription set to synchronize with the server.

Asynchronously wait for the subscription set to synchronize with the server.

String name
)

Encuentra la suscripción con un nombre determinado.

Parámetros

  • name - nombre de la suscripción para buscar.

Devuelve

the matching subscription or null if no subscription with that name was found.

Find the first subscription that contains the given query. It is possible for multiple named subscriptions to contain the same query.

Parámetros

  • query - query para buscar.

Devuelve

the first subscription containing the query or null if no match was found.

If getState() returns State.ERROR , this method will return the reason. Errors can be fixed by modifying the subscription accordingly and then calling waitForSynchronization() .

Devuelve

the underlying error if the subscription set is in the State.ERROR state. For all other states null will be returned.

Devuelve el estado actual del SubscriptionSet. Consulte SubscriptionSet.State para obtener más detalles sobre cada estado.

Devuelve

estado actual del SubscriptionSet.

public int size ()

Returns how many subscriptions are currently in this subscription set.

Devuelve

the number of of subscriptions in the subscription set.

Modify the subscription set. If an exception is thrown during the update, no changes will be applied. If the update succeeds, this subscription set is updated with the modified state.

Parámetros

  • action El bloque que modifica el conjunto de suscripciones. Se ejecutará en el hilo de llamada.

Devuelve

este conjunto de suscripción, que ahora ha sido actualizado.

Throws

  • Excepción: cualquier excepción lanzada durante la actualización se propagará hacia atrás.

Modificar asincrónicamente el conjunto de suscripciones. Si se genera una excepción durante la actualización, no se aplicarán los cambios. *

Parámetros

  • callback - callback that controls the asynct ask. Succces or failure will be reported here.

Devuelve

Tarea que controla la ejecución asincrónica.

public boolean waitForSynchronization (
Long timeOut,
)

Espera a que el conjunto de suscripción se sincronice con el servidor. Devuelve cuando el servidor acepta el conjunto de queries y ha descargado datos para ellas, o si se ha producido un error. Ten en cuenta que necesitarás llamar manualmente a Realm.refresh() o esperar a que los oyentes de cambios se activen para ver los datos descargados. Si ocurre un error, la razón subyacente se puede encontrar a través de getErrorMessage() .

Parámetros

  • timeOut - cuánto tiempo esperar a que la sincronización tenga éxito o falle.

  • unit - unidad de tiempo utilizada para el tiempo de espera.

Devuelve

true if all current subscriptions were accepted by the server and data has been downloaded, or false if an error occurred.

Throws

public boolean waitForSynchronization ()

Espera a que el conjunto de suscripción se sincronice con el servidor. Devuelve cuando el servidor acepta el conjunto de queries y ha descargado datos para ellas, o si se ha producido un error. Ten en cuenta que necesitarás llamar manualmente a Realm.refresh() o esperar a que los oyentes de cambios se activen para ver los datos descargados. Si ocurre un error, la razón subyacente se puede encontrar a través de getErrorMessage() .

Devuelve

true if all current subscriptions were accepted by the server and data has been downloaded, or false if an error occurred.

Asynchronously wait for the subscription set to synchronize with the server. The callback is invoked when the server either accepts the set of queries and has downloaded data for them, or if an error has occurred. Note, that you will either need to manually call Realm.refresh() or wait for change listeners to trigger to see the downloaded data. If an error occurred, the underlying reason can be found through getErrorMessage() .

Parámetros

  • timeOut - cuánto tiempo esperar a que la sincronización tenga éxito o falle.

  • unit - unidad de tiempo utilizada para el tiempo de espera.

  • callback - callback to trigger when the synchronization either succeed or fail. Results will be reported on the UI thread.

Devuelve

true if all current subscriptions were accepted by the server and data has been downloaded, or false if an error occurred.

Espera de manera asíncrona a que el conjunto de suscripción se sincronice con el servidor. Invocará la función de retorno cuando el servidor acepte el conjunto de queries y haya descargado datos para ellas, o si se produce algún error. Ten en cuenta que necesitarás llamar manualmente a Realm.refresh() o esperar a que los oyentes de cambios se activen para ver los datos descargados. Si ocurre un error, la razón subyacente se puede encontrar a través de getErrorMessage() .

Parámetros

  • callback - callback to trigger when the synchronization either succeed or fail. Results will be reported on the UI thread.

Devuelve

true if all current subscriptions were accepted by the server and data has been downloaded, or false if an error occurred.

Volver

Suscripción

En esta página