declex icon indicating copy to clipboard operation
declex copied to clipboard

Autogenerated Classes

Open smaugho opened this issue 7 years ago • 0 comments

It would be useful to create Autogenerated Classes (these are created directly from the code itself). This would permit to program faster States and encapsulate the code easier...

Ex.


@Autogenerate
State state;

@Click
void buttonPressed() {
    state.buttonSelected = !state.buttonSelected;
}

void someAction() {
    $MainActivity();
    state.mainActivityCalled = true;
}

The main idea is to easily create "Record Classes" to store states, parameters. See that for doing this, it is necessary to infer the types for the fields...

The way to use it it is simply assign a value, run a build (in Android Studio) and continue programming... the build will auto-generate the class in the current package, so it would be automatically visible for the current enhanced class using this feature.

This can be used as well as parameter for methods (specially methods that would be used for injection):


@Click
void saveUser(@Autogenerate UserState userState) {
    userState.param = "some string value";
    //...
}

smaugho avatar Mar 17 '17 10:03 smaugho