Java Code Examples for io.objectbox.reactive.DataObserver#onData()

The following examples show how to use io.objectbox.reactive.DataObserver#onData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ObjectClassPublisher.java    From objectbox-java with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    try {
        while (true) {
            // We do not join all available array, just in case the app relies on a specific order
            int[] entityTypeIdsAffected;
            synchronized (changesQueue) {
                entityTypeIdsAffected = changesQueue.pollFirst();
                if (entityTypeIdsAffected == null) {
                    changePublisherRunning = false;
                    break;
                }
            }
            for (int entityTypeId : entityTypeIdsAffected) {
                Collection<DataObserver<Class>> observers = observersByEntityTypeId.get(entityTypeId);
                if (observers != null && !observers.isEmpty()) {
                    Class<?> objectClass = boxStore.getEntityClassOrThrow(entityTypeId);
                    try {
                        for (DataObserver<Class> observer : observers) {
                            observer.onData(objectClass);
                        }
                    } catch (RuntimeException e) {
                        handleObserverException(objectClass);
                    }
                }
            }
        }
    } finally {
        // Just in Case of exceptions; it's better done within synchronized for regular cases
        changePublisherRunning = false;
    }
}
 
Example 2
Source File: FakeQueryPublisher.java    From ObjectBoxRxJava with Apache License 2.0 4 votes vote down vote up
@Override
public void publishSingle(final DataObserver<List<T>> observer, Object param) {
    observer.onData(queryResult);
}
 
Example 3
Source File: FakeQueryPublisher.java    From ObjectBoxRxJava with Apache License 2.0 4 votes vote down vote up
public void publish() {
    for (DataObserver<List<T>> observer : observers) {
        observer.onData(queryResult);
    }
}
 
Example 4
Source File: FakeQueryPublisher.java    From objectbox-java with Apache License 2.0 4 votes vote down vote up
@Override
public void publishSingle(final DataObserver<List<T>> observer, @Nullable Object param) {
    observer.onData(queryResult);
}
 
Example 5
Source File: FakeQueryPublisher.java    From objectbox-java with Apache License 2.0 4 votes vote down vote up
public void publish() {
    for (DataObserver<List<T>> observer : observers) {
        observer.onData(queryResult);
    }
}
 
Example 6
Source File: FakeQueryPublisher.java    From objectbox-java with Apache License 2.0 4 votes vote down vote up
@Override
public void publishSingle(final DataObserver<List<T>> observer, Object param) {
    observer.onData(queryResult);
}
 
Example 7
Source File: FakeQueryPublisher.java    From objectbox-java with Apache License 2.0 4 votes vote down vote up
public void publish() {
    for (DataObserver<List<T>> observer : observers) {
        observer.onData(queryResult);
    }
}