room/rxjava2/src/main/java/androidx/room/RxRoom.java
public static Flowable<Object> createFlowable(final RoomDatabase database,
            final String... tableNames) {
        return Flowable.create(new FlowableOnSubscribe<Object>() {
            @Override
            public void subscribe(final FlowableEmitter<Object> emitter) throws Exception {
                final InvalidationTracker.Observer observer = new InvalidationTracker.Observer(
                        tableNames) {
                    @Override
                    public void onInvalidated(@androidx.annotation.NonNull Set<String> tables) {
                        if (!emitter.isCancelled()) {
                            emitter.onNext(NOTHING);
                        }
                    }
                };
                if (!emitter.isCancelled()) {
                    database.getInvalidationTracker().addObserver(observer);
                    emitter.setDisposable(Disposables.fromAction(new Action() {
                        @Override
                        public void run() throws Exception {
                            database.getInvalidationTracker().removeObserver(observer);
                        }
                    }));
                }

                // emit once to avoid missing any data and also easy chaining
                if (!emitter.isCancelled()) {
                    emitter.onNext(NOTHING);
                }
            }
        }, BackpressureStrategy.LATEST);
    }
/**
     * Creates a {@link Flowable} that emits at least once and also re-emits whenever one of the
     * observed tables is updated.
     * <p>
     * You can easily chain a database operation to downstream of this {@link Flowable} to ensure
     * that it re-runs when database is modified.
     * <p>
     * Since database invalidation is batched, multiple changes in the database may results in just
     * 1 emission.
     *
     * @param database   The database instance
     * @param tableNames The list of table names that should be observed
     * @return A {@link Flowable} which emits {@link #NOTHING} when one of the observed tables
     * is modified (also once when the invalidation tracker connection is established).
     */
Creates a  Flowable that emits at least once and also re-emits whenever one of the
observed tables is updated.

You can easily chain a database operation to downstream of this  Flowable to ensure
that it re-runs when database is modified.

Since database invalidation is batched, multiple changes in the database may results in just
1 emission.

@param database   The database instance
@param tableNames The list of table names that should be observed
@return A  Flowable which emits  #NOTHING when one of the observed tables
is modified (also once when the invalidation tracker connection is established).
Creates a Flowable that emits at least once and also re - emits whenever one of the observed tables is updated . You can easily chain a database operation to downstream of this Flowable to ensure that it re - runs when database is modified . Since database invalidation is batched multiple changes in the database may results in just 1 emission . @param database The database instance @param tableNames The list of table names that should be observed @return A Flowable which emits #NOTHING when one of the observed tables is modified ( also once when the invalidation tracker connection is established ) .
public static Flowable<Object> createFlowable(final RoomDatabase database,
            final String... tableNames) {
        return Flowable.create(new FlowableOnSubscribe<Object>() {
            @Override
            public void subscribe(final FlowableEmitter<Object> emitter) throws Exception {
                final InvalidationTracker.Observer observer = new InvalidationTracker.Observer(
                        tableNames) {
                    @Override
                    public void onInvalidated(@androidx.annotation.NonNull Set<String> tables) {
                        if (!emitter.isCancelled()) {
                            emitter.onNext(NOTHING);
                        }
                    }
                };
                if (!emitter.isCancelled()) {
                    database.getInvalidationTracker().addObserver(observer);
                    emitter.setDisposable(Disposables.fromAction(new Action() {
                        @Override
                        public void run() throws Exception {
                            database.getInvalidationTracker().removeObserver(observer);
                        }
                    }));
                }
                if (!emitter.isCancelled()) {
                    emitter.onNext(NOTHING);
                }
            }
        }, BackpressureStrategy.LATEST);
    }
public static Flowable < Object > createFlowable ( final RoomDatabase database , final String ... tableNames ) { return Flowable . create ( new FlowableOnSubscribe < Object > ( ) { @ Override public void subscribe ( final FlowableEmitter < Object > emitter ) throws Exception { final InvalidationTracker . Observer observer = new InvalidationTracker . Observer ( tableNames ) { @ Override public void onInvalidated ( @ androidx . annotation . NonNull Set < String > tables ) { if ( ! emitter . isCancelled ( ) ) { emitter . onNext ( NOTHING ) ; } } } ; if ( ! emitter . isCancelled ( ) ) { database . getInvalidationTracker ( ) . addObserver ( observer ) ; emitter . setDisposable ( Disposables . fromAction ( new Action ( ) { @ Override public void run ( ) throws Exception { database . getInvalidationTracker ( ) . removeObserver ( observer ) ; } } ) ) ; } if ( ! emitter . isCancelled ( ) ) { emitter . onNext ( NOTHING ) ; } } } , BackpressureStrategy . LATEST ) ; }
Creates a {@link Flowable} that emits at least once and also re-emits whenever one of the
 observed tables is updated.
Creates a { @link Flowable } that emits at least once and also re - emits whenever one of the observed tables is updated .
// emit once to avoid missing any data and also easy chaining