Skip to content

Transaction for entities proceeded by RXJava observer with DBFlow #1732

@quillalady

Description

@quillalady

DBFlow Version: 5.0.0-alpha1

Bug or Feature Request: Question

Description:

How to use DBFlow transaction for RXJava observer so that the transaction is for whole stream of items proceeded by the observer? My attempt is:

new Observer<Item>() {
          @Override
          public void onSubscribe(@NonNull Disposable d) {
            FlowManager.getDatabase(AppDatabase.class).beginTransaction();
          }

          @Override
          public void onNext(@NonNull Item item) {
            FlowManager.getModelAdapter(Item.class).save(item, FlowManager.getDatabase(AppDatabase.class));
          }

          @Override
          public void onError(@NonNull Throwable error) {
          }

          @Override
          public void onComplete() {
            FlowManager.getDatabase(AppDatabase.class).endTransaction();
          }
        };

But beginTransaction() blocks processing of items.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions