You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
builder.putElement(slot, new ActionableElement(
new RunnableAction(container, ActionType.NONE, "", context -> {}),
item
));
This is messy for a number of reasons:
There is no reason to provide the StateContainer to an Action - context can be passed when necessary.
Even if the ActionType is NONE, you still have to pass a goalState. Even though this could be made a default property of an Action, such that if only the container and effective consumer (context -> {}) is passed, it still isn't as clean as it could be. In reality, goalState logic is just another consumer permanently attached to the Action, when they could easily be merged together.
Here, ActionContext replaces what was initially RunnableAction and replaces the functionality of the consumer, however here it is not the RunnableAction passed into the anonymous function - it is an object specifically for the runnable's context.
To replace the functionality of goalState transition being easily requested with ActionType I propose Actions.GO and Actions.BACK, where Actions is an interface consisting of static default Consumer<ActionContext which automatically change the state.
Actions.GO could be defined as state -> context -> context.setState(state), which allows the use of Actions.GO("some_state").
Actions.BACK could be defined context -> context.setState(context.getParent()) or just context -> context.back(). It is useful to shorten this, because of the following scenario.
new ActionableElement(item, context -> {
context.getObserver().sendMessage(...);
context.back();
});
This allows for the previous functionality where a runnable can be executed AND the state can be changed at once.
The text was updated successfully, but these errors were encountered:
Regarding this API usage:
This is messy for a number of reasons:
StateContainer
to anAction
- context can be passed when necessary.ActionType
isNONE
, you still have to pass agoalState
. Even though this could be made a default property of anAction
, such that if only the container and effective consumer (context -> {}
) is passed, it still isn't as clean as it could be. In reality,goalState
logic is just another consumer permanently attached to theAction
, when they could easily be merged together.I propose:
Here,
ActionContext
replaces what was initiallyRunnableAction
and replaces the functionality of the consumer, however here it is not theRunnableAction
passed into the anonymous function - it is an object specifically for the runnable's context.To replace the functionality of
goalState
transition being easily requested withActionType
I proposeActions.GO
andActions.BACK
, whereActions
is an interface consisting of static defaultConsumer<ActionContext
which automatically change the state.Actions.GO
could be defined asstate -> context -> context.setState(state)
, which allows the use ofActions.GO("some_state")
.Actions.BACK
could be definedcontext -> context.setState(context.getParent())
or justcontext -> context.back()
. It is useful to shorten this, because of the following scenario.This allows for the previous functionality where a runnable can be executed AND the state can be changed at once.
The text was updated successfully, but these errors were encountered: