jvm-redux / jvm-redux-api

MIT License
22 stars 4 forks source link

Add Action interface #15

Closed AZZB closed 7 years ago

AZZB commented 7 years ago

Hello, I can use it like this:

`

  public class MyAction implement redux.api.Action<ActionType, String> {

        private ActionType type;
        private String payload;

        public MyAction(ActionType type, String payload) {
              this.type = type;
              this.payload = payload;
        }

        @Override
        public ActionType getType() {
            return type;
        }

        @Override
        public String getPayload() {
           return payload;
        }
} 

` -thanks you

AngusMorton commented 7 years ago

I don't think we should define an Action interface.

This interface is too specific and doesn't allow people to be flexible in their Action definition or usage. For instance, I tend to use the type of the class to differentiate between Action types.

Can you provide a use case that the existing API doesn't support?

pardom-zz commented 7 years ago

It appears you're trying to implement something like FSA (https://github.com/acdlite/flux-standard-action), which is best left as a library. The original Redux library defines an action as a plain object.