I have an Android project that currently doesn't use View Models or rxJava. It's a fairly straightforward app that uses the Parse sdk with a parse-server. It's still early in the project and I've decided to start using VM and rxJava.
My question is mostly about structure, naming etc. Let's use Login for an example:
I have an interface calledAuthenticationService.java
with a login(Authorization auth, ServiceCallback<User> callback)
method.
My ParseAuthenticationService.java
implements that interface and does all the parse stuff.
The whole app is set up like that, so my User.java
is an interface used by MyParseUser.java
where all the parse stuff happens.
So there's a login button, LoginActivity
grabs the username/password, makes an Authorization object and calls the login function.
Is the change to rxJava as simple as wrapping the login
function in an observable and subscribing to it in the activity?
What would that look like? The login function looks like this:
@Override
public void login(Authorization authorization, final ServiceCallback<User> callback)
{
cachedUser = null;
ParseUser.logInInBackground(authorization.getUsername(), authorization.getPassword(), new LogInCallback()
{
@Override
public void done(ParseUser user, ParseException e)
{
if (callback != null)
{
callback.onServiceRequestComplete(Response.<User>from((MyParseUser) user, e));
}
}
});
}
Can I keep the same Parse-class-using-generic-interface structure? Or should I restructure/rename my files?
Thanks for any help. This is all a bit overwhelming.