marcelpinto / RxFlux

RxFlux is a small framework in order to follow Flux design pattern with RxJava functionalities

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Some stuff....

AndreiD opened this issue · comments

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 ? 👍

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 ?

    switch (change.getStoreId()) {
      case RepositoriesStore.ID:
        switch (change.getRxAction().getType()) {
          case Actions.GET_PUBLIC_REPOS:
            adapter.setRepos(repositoriesStore.getRepositories());
            break;
        }
        break;
      case UsersStore.ID:
        switch (change.getRxAction().getType()) {
          case Actions.GET_USER:
            showUserDialog((String) change.getRxAction().getData().get(Keys.ID));
        }
    }

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...

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.

  1. To use the style, you must get the xml file in the link and install it using the instructions at the same link. Once you did that, then you can select this style in the Settings of the Android Studio. This will make your IDE follow the defined style so when you modify code or send a PR you will keep the style.
  2. What do you understand by "100% committed"? I am working during the day and RxFlux was created on my free time, I definitely pretend to keep working on it and improve but I have limited time and resources. Hopefully more people will use and the community will keep improving it.
  3. Is used in one private enterprise project and in my next personal project (not available yet).

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.