@@ -54,7 +54,29 @@ enum ActionType {
5454 }
5555}
5656
57- /// Holds information about an action to perform on a user interaction.
57+ /// The [ActionModel] class is a representation of an interactive action
58+ /// that a program can execute based on a user's interaction.
59+ ///
60+ /// Each [ActionModel] instance contains a specific [ActionType] , which
61+ /// determines the type of action that needs to be performed.
62+ ///
63+ /// The class supports serialization and deserialization from JSON,
64+ /// allowing for easy storage, retrieval, and transmission of action data.
65+ ///
66+ /// It is an abstract class, meant to be subclassed for specific types of actions.
67+ /// The specific action classes are determined by the [ActionType] enumeration.
68+ ///
69+ /// This class also implements the Visitor pattern via the [accept] method.
70+ /// This allows for type-specific computations or actions to be performed
71+ /// on an [ActionModel] instance without the need for type checking or casting.
72+ ///
73+ /// For example, the [ActionModel] class can represent various types of actions
74+ /// such as navigation, link, submit, setValue, setVariant, setVariable,
75+ /// callFunction, and callApi. Each of these action types can be handled
76+ /// differently based on the requirements of the application.
77+ ///
78+ /// This design provides a flexible and extensible way to manage actions
79+ /// in response to user interactions.
5880abstract class ActionModel with SerializableMixin {
5981 /// Type of the action.
6082 ActionType type;
@@ -86,5 +108,18 @@ abstract class ActionModel with SerializableMixin {
86108 }
87109 }
88110
111+ /// Applies the visitor pattern to this [ActionModel] .
112+ ///
113+ /// The [accept] function takes a visitor object and calls the appropriate
114+ /// visit method on the visitor, according to the runtime type of this [ActionModel] .
115+ /// This allows the visitor to perform computations or actions depending on
116+ /// the specific subclass of [ActionModel] it is dealing with.
117+ ///
118+ /// The return value is the result of calling the visit method on the visitor.
119+ /// The visitor is responsible for specifying the return type [R] .
120+ ///
121+ /// @param visitor The visitor object to apply to this [ActionModel] .
122+ ///
123+ /// @returns The result of calling the visit method on the visitor.
89124 R ? accept <R >(ActionVisitor <R > visitor);
90125}
0 commit comments