DSpotDevelopers / declex

DecleX - Declarative Framework for Android, easier and faster coding.
Other
168 stars 25 forks source link

@LoadOnEvent and @UpdateOnEvent using events with params #129

Open yasmanmesa opened 7 years ago

yasmanmesa commented 7 years ago

If you create events with parameters, and then they are used to reload a model, an error is generated since no parameter is recognized. Suppose we have an event like this:

    @Event
    void onSomeEvent(boolean show) {
        some_view.setVisible(show);
    }

Then we use this event to reload a model, something like this:

    @Model
    @Populate
    @LoadOnEvent(SomeEvent.class)
    List<User_> someList;

These annotations, @LoadOnEvent and @UpdateOnEvent, construct the event without parameters, although it was previously declared with a parameter. DecleX should choose the most parameters and generate the event.

smaugho commented 7 years ago

Thanks for reporting.

smaugho commented 7 years ago

The best solution to this issue is that DecleX should create the event with all the parameters that has been passed from any method, so that the event can fulfill any interface, an action should be done for each one of those methods, so if you have

@Event
void onSomeEvent(String param1, String param2) {

}

@Event
void onSomeEvent(String param3, String param2) {

}

This would create an event with 3 parameters, and with the actions

$SomeEvent(param1, param2);
$SomeEvent(param3, param2);

If a parameter is passed with the same name and 2 different types, 2 versions of the param will be created, since it is used different actions for each Action, the framework can decide what param is being referenced, so

@Event
void onSomeEvent(String param) {

}

@Event
void onSomeEvent(int param) {

}

This would create in the action param$1, param$2, which will be used depending of what is sent...