Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction for entities proceeded by RXJava observer with DBFlow #1732

Open
quillalady opened this issue Jul 8, 2022 · 0 comments
Open

Comments

@quillalady
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant