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

Update to RxJava2 #239

Closed
wants to merge 5 commits into from
Closed

Update to RxJava2 #239

wants to merge 5 commits into from

Conversation

dsrees
Copy link

@dsrees dsrees commented Nov 3, 2017

Closes #208 and updates the code to use io.reactivex classes instead of rx classes. This PR also makes #223 obsolete. Also updated the Retrofit2 RxJava adapter to the RxJava2 adapter.

In the process I also updated Retrofit from 2.0.0-beta4 to 2.3.0 and OkHttp from 3.5.0 to 3.8.0. This had some repercussions with ChangeableBaseUrl which I believe I resolved correctly but please check. This would also make #236 obsolete though that PR overhauls ChangeableBaseUrl and upgrades OkHttp to 3.9.0 while Retrofit 2.3.0 is using OkHttp 3.8.0 under the hood.

All tests are ✅

try {
disposeAction.run();
} catch (Exception e) {
throw new RuntimeException(e); // RxJava2 Action throws an exception. Pass it on
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rethrow here or use the RxJavaPlugins?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check out the updated implementation which converts FinishAsyncJobSubscription into FinishAsyncJobAction and passes it through to Disposables.fromAction(finishAsyncJobAction)

import rx.functions.Action0;

public class DisposableSubscription implements Subscription {
public class DisposableSubscription implements Disposable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this could be solved with Disposables.from instead

rxLint : '1.6',
supportLibs : '23.1.1',
okHttp : '3.2.0',
retrofit : '2.0.0-beta4',
okHttp : '3.8.0',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's 3.9.0

@dsrees
Copy link
Author

dsrees commented Nov 3, 2017

Updated based on review. Not sure why the travis job is failing, but it seems to be failing for all recent PRs. Is this something I can fix in this PR?

@artem-zinnatullin
Copy link
Owner

Sorry, I'm at KotlinConf and then will spend weekend with friends who also came to conference and then DroidconSF and work…

I've added this to my todo list and hopefully will review in the middle of next week, apologies 😬

I really trust @vanniktech, so you can definitely continue addressing his comments 😸

@vanniktech
Copy link
Contributor

I don't think that we need the FinishAsyncJobSubscription class at all. Simply using one of the Disposables should do the job:

Disposables.fromRunnable(Runnable run) // Construct a Disposable by wrapping a Runnable that is executed exactly once when the Disposable is disposed.
Disposables.fromAction(Action run) // Construct a Disposable by wrapping a Action that is executed exactly once when the Disposable is disposed.

@dsrees
Copy link
Author

dsrees commented Nov 8, 2017

  • Removed DisposableSubscription and test
  • Removed FinishAsyncJobAction and test
  • Using single lambda expression Disposables.fromAction(() -> asyncJobsObserver.asyncJobFinished(asyncJob)) in place of FinishAsyncJobAction
  • Added test to ensure that the async job action was finished if the Disposable was disposed of.

Copy link
Contributor

@vanniktech vanniktech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from RxJava 2 side.

As for the ChangeableBaseUrl, I'll leave it up to Artem how / if that class needs a change.

Seems like CI is failing since the logs are flooded?

@vanniktech
Copy link
Contributor

@danielrees18 is this on the latest master branch? If not, rebasing should fix the build issue.

@dsrees
Copy link
Author

dsrees commented Dec 27, 2017 via email

Copy link
Contributor

@vanniktech vanniktech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good on my side.

As for the ChangeableBaseUrl, I'll leave it up to @artem-zinnatullin how / if that class needs a change.

@mibrahimdev
Copy link

is there any updates on this PR, interested to see Rxjava2 in this project to experiment with it.

@artem-zinnatullin
Copy link
Owner

ProGuard config needs an update, build fails https://api.travis-ci.org/v3/job/323862434/log.txt

@dsrees dsrees closed this May 10, 2022
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

Successfully merging this pull request may close these issues.

Upgrade RxJava 1 to RxJava 2
4 participants