Skip to content

SimpleAction

dendron.actions.simple_action.SimpleAction

Bases: ActionNode

A simple action node is initialized with a callback that is called every time this node tick()s. The callback should be a function that that returns a NodeStatus.

Parameters:

Name Type Description Default
name `str`

The given name of this node.

required
callback `Callable`

The callback to be executed upon every tick().

required
Source code in src/dendron/actions/simple_action.py
class SimpleAction(ActionNode):
    """
    A simple action node is initialized with a callback that is 
    called every time this node `tick()`s. The callback should
    be a function that that returns a `NodeStatus`.

    Args:
        name (`str`):
            The given name of this node.
        callback (`Callable`):
            The callback to be executed upon every `tick()`.
    """
    def __init__(self, name : str, callback : Callable) -> None:
        super().__init__(name)
        self.callback = callback

    def tick(self) -> NodeStatus:
        """
        Call the callback function and return its status as the
        node status.
        """
        return self.callback() 

tick()

Call the callback function and return its status as the node status.

Source code in src/dendron/actions/simple_action.py
def tick(self) -> NodeStatus:
    """
    Call the callback function and return its status as the
    node status.
    """
    return self.callback()