declex icon indicating copy to clipboard operation
declex copied to clipboard

@LoadOnEvent and @UpdateOnEvent using events with params

Open yasmanmesa opened this issue 7 years ago • 2 comments

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.

yasmanmesa avatar Mar 30 '17 17:03 yasmanmesa

Thanks for reporting.

smaugho avatar Mar 30 '17 18:03 smaugho

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

smaugho avatar Mar 31 '17 00:03 smaugho