Closed AndreiD closed 8 years ago
ok, now i see, the key id is used in onRetry....
Hi @AndreiD, I am happy you decide to play with RxFlux. Let's go one by one.
Notice that this is just an implementation of Flux pattern applied with RxJava, I recommend to use it since it makes it easy and give nice functionalities, but in case you won't like it or feel comfortable with it I still recommend to us Flux pattern.
About "retry" I implemented it in the example of the lib. (I recently update the code)
@Override
public void onRxError(RxError error) {
setLoadingFrame(false);
Throwable throwable = error.getThrowable();
if (throwable != null) {
Snackbar.make(coordinatorLayout, "An error ocurred", Snackbar.LENGTH_INDEFINITE)
.setAction("Retry",
v -> SampleApp.get(this).getGitHubActionCreator().retry(error.getAction()))
.show();
} else {
Toast.makeText(this, "Unknown error", Toast.LENGTH_LONG).show();
}
}
As you can see I get the action from the error and send it again to the ActionCreator so it can handle the retry.
Last thing, the ID you mention is just from the example, it does not come from the library. This ID is to get a data from the Action that I decided that will use as key the word "ID".
The other ID you mention is the Store ID, this one is important in order to distinguish in the VIEW where the change come from.
@Override
public void onRxStoreChanged(RxStoreChange change) {
switch (change.getStoreId()) {
case RepositoriesStore.ID:
...
break;
case UsersStore.ID:
...
}
}
Last questions about combine Actions and Keys. An RxAction contains and Action type that this will contains a key-value pair data. Meaning that you need to define a type of Action and then you use Keys to define the data that an RxAction will contain. (I am not sure if I explained good...)
But I would recommend you to take a look at the code of the library, since Actions and Keys are defined by you and not the library. I created a wiki page that will help you
note: for people that use Android Studio under windows. Copy the SquareAndroid.xml in C:\users\your_username.android-studio\config\codestyles. Restart Android Studio. Go to Settings and select it in Code Styles. CTRL+ALT+L to format it.
My previous app had like 20 endpoints... spaghetti code. so this is why I end-up reading about architecture, and ended up in your blog post and library...
I want to contribute, but I'm afraid I'm not so experienced.... what do those push style mean ? :+1:
some things that I noticed.
are you committed 100% to maintain this library in the future ? you use it in your projects ?
in your blog post on medium there are some things missing, like the "retry" action, without it app crashes on errors (rx complains that there's no error handler).
Other: What's the point of String ID = "id"; in the Keys interface. It's not used. You have a static string ID inside the store... this is a little confusing.
Could it be another way to do this, and not by having switches inside switches ?
Both Actions and Keys interfaces seem very similar to me, is there a way to combine them into one ?
Ill try next days to play more with it...