The Greycat AdditionaL Actions (gala) project is a plugin for Greycat providing additional actions to the one offered by Greycat.
Actions are reusable elements hiding low-level, asynchronous task primitives behind an expressive API. Actions allows to traverse and manipulate the graph and can be chained to form a task.
A great number of action are already implemented and available in Greycat, please refer to the greycat.internal.task package of Greycat.
However, thinking and implementing every possible actions would:
- be impossible
- drastically increase the size of the project.
That's why only basic, i.e., atomic, actions are implemented.
Yet, users might need more composed actions like Injecting an object as a variable or Putting the result of a get action in a variable instead of in the result.
Thus this project has the following objectives:
- offer more complex general purpose actions
- provide an example of Actions development to developers eager to develop some for their own need :)
Currently offered actions are:
- Check For Future
- Count
- Execute at World and Time
- If empty then
- If empty then else
- If not empty then
- If not empty then else
- Inject as Var
- Increment
- Keep first result
- Flip Vars
- Flip Var And Result
- Read Updated Time Var
This plugin can be used the same way as other Greycat plugins.
1 . Declare the plugin in your Graph Build
Graph g = new GraphBuilder()
.withPlugin(new ActionsPlugin())
.build();
2 . Then call action(MyAction.Name) in your task chain or use then(Actions.myaction()) to launch it.
newTask()
.action(ActionIncrement.NAME,"myvar","1")
.then(Actions.count())
Please Note that the first option is usable for almost all of the actions and works seamlessly in java or javascript. On the other hand, a function like injectAsVar that require a native object can only be called using then and can not be used from javascript.
3 . That's all =)