{"id":13744044,"url":"https://github.com/alebianco/robotlegs-utilities-macrobot","last_synced_at":"2026-01-11T01:50:27.319Z","repository":{"id":8004580,"uuid":"9412351","full_name":"alebianco/robotlegs-utilities-macrobot","owner":"alebianco","description":"Macro command utility for Robotlegs which provides the ability to execute batches of commands in sequential or parallel fashion.","archived":true,"fork":false,"pushed_at":"2016-12-08T11:34:12.000Z","size":3070,"stargazers_count":17,"open_issues_count":2,"forks_count":6,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-08-04T05:03:01.728Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"ActionScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alebianco.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-13T10:56:59.000Z","updated_at":"2023-01-27T19:36:06.000Z","dependencies_parsed_at":"2022-09-03T10:11:33.549Z","dependency_job_id":null,"html_url":"https://github.com/alebianco/robotlegs-utilities-macrobot","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alebianco%2Frobotlegs-utilities-macrobot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alebianco%2Frobotlegs-utilities-macrobot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alebianco%2Frobotlegs-utilities-macrobot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alebianco%2Frobotlegs-utilities-macrobot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alebianco","download_url":"https://codeload.github.com/alebianco/robotlegs-utilities-macrobot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224802925,"owners_count":17372531,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T05:01:01.899Z","updated_at":"2026-01-11T01:50:27.280Z","avatar_url":"https://github.com/alebianco.png","language":"ActionScript","funding_links":[],"categories":["Frameworks"],"sub_categories":["RobotLegs Framework"],"readme":"# Macrobot\n\n[![Build Status](https://travis-ci.org/alebianco/robotlegs-utilities-macrobot.svg?branch=master)](https://travis-ci.org/alebianco/robotlegs-utilities-macrobot)\n\nMacro command utility for Robotlegs which provides the ability to execute batches of commands in sequential or parallel fashion.\n\n**NOTE** This project is a shameful port of the awesome work that [Aaronius](https://github.com/Aaronius) made for the first release of [Robotlegs](http://www.robotlegs.org/).\n\n## Introduction\n\nWhile using Robotlegs and encapsulating your business logic inside commands, you may find yourself in a situation where you wish to batch commands, instead of relying on events to trigger every step.  \nMacrobot simplifies this process and provide two way to group commands:\n\n**Sequence**: The commands will be executed in order one after the other. A command will not be executed until the previous one is complete. The macro itself will not be complete until all its commands are complete.\n\n**Parallel**: The commands will be executed as quickly as possible, with no regards on the order in which they were registered. The macro itself will not be complete until all its commands are complete.\n\n# Releases\n\nYou'll find new versions of the extension in the [Releases page](https://github.com/alebianco/robotlegs-utilities-macrobot/releases) of the repository.\n\n## Usage\n\nTo create a macro command, extend on the two classes Macrobot provides: `ParallelMacro` or `SequenceMacro`.  \nOverride the prepare() method and add sub commands by calling `addSubCommand()` specifying the command class to use.  \nAt the appropriate time the command will be created, initiated by satisfying the injection points and then executed.  \nThis automated process of instantiation, injection, and execution is very similar to how commands are normally prepared and executed in Robotlegs.  \nYou could use _Guards_ and _Hooks_ as you would normally use with regular commands to control the execution workflow.  \nAdditionally you could use the `withPayloads()` method to add some data that can be used to satisfy the injection points of the sub commands. The data provided will be available to the guards and hooks applied to the sub command as well.\n\nHere's an example of a simple sequential macro:\n```ActionScript\npublic class MyMacro extends SequenceMacro {\n\toverride public function prepare() {\n\t\tadd(CommandA);\n\t\tadd(CommandB);\n\t\tadd(CommandC);\n\t}\n}\n```\n\n### Using Guards\n\nGuards are used to approve or deny the execution of one of the subcommands.\n\n```ActionScript\npublic class DailyRoutine extends SequenceMacro {\n\toverride public function prepare() {\n\t\tadd(Work);\n\t\tadd(Party).withGuards(IsFriday); // It will only party on fridays\n\t\tadd(Sleep);\n\t}\n}\n\npublic class IsFriday implements IGuard {\n\tpublic funciton approve():Boolean {\n\t\treturn new Date().day == 5;\n\t}\n}\n```\nRefer to the [Robotlegs documentation](https://github.com/robotlegs/robotlegs-framework/blob/master/src/robotlegs/bender/framework/readme-guards.md) for more details about Guards.\n\n### Using Hooks\n\nHooks run before the subcommands. They are typically used to run custom actions based on environmental conditions.  \nHooks will run only if the applied Guards approve the execution of the command.\n\n```ActionScript\npublic class DailyRoutine extends SequenceMacro {\n\toverride public function prepare() {\n\t\tadd(Work);\n\t\tadd(Party).withGuards(IsFriday); // It will only party on fridays\n\t\tadd(Sleep).withHook(GoToHome); // Try to avoid sleeping at the office or the pub\n\t}\n}\n\npublic class IsFriday implements IHook {\n\t[Inject] public var me:Person;\n\tpublic funciton hook():void {\n\t\tme.goHome();\n\t}\n}\n```\nRefer to the [Robotlegs documentation](https://github.com/robotlegs/robotlegs-framework/blob/master/src/robotlegs/bender/framework/readme-hooks.md) for more details about Hooks.\n\n\n### Using Payloads\n\nPayloads are used to temporary inject some data, which would not be available otherwise, and make it available to the subcommand, it's guards and it's hooks.  \n\nYou can use pass the data to be injected directly to the `withPayloads()` method, for a normal injection.\n```ActionScript\npublic class Macro extends SequenceMacro {\n\toverride public function prepare() {\n\t\tconst data:SomeModel = new SomeModel()\n\t\tadd(Action).withPayloads(data);\n\t}\n}\n\npublic class Action implements ICommand {\n\t[Inject] public var data:SomeModel;\n\tpublic function execute():void {\n\t\tdata.property = 'value'\n\t}\n}\n```\n\nOr you can use the `SubCommandPayload` class to create a more complex injection.\n```ActionScript\npublic class Macro extends SequenceMacro {\n\toverride public function prepare() {\n\t\tconst data:SomeModel = new SomeModel()\n\t\tconst payload:SubCommandPayload = new SubCommandPayload(data).withName('mydata').ofClass(IModel)\n\t\tadd(Action).withPayloads(payload);\n\t}\n}\n\npublic class Action implements ICommand {\n\t[Inject(name='mydata')] public var data:IModel;\n\tpublic function execute():void {\n\t\tdata.property = 'value'\n\t}\n}\n```\n\n### Asynchronous commands\n\nWhile Macrobot can work with synchronous commands, it is most effective when you have to deal with asynchronous ones.  \nYour sub command may wait for a response from a server or for user interaction before being marked as complete.  \nIn this case you command can subclass Macrobot's AsyncCommand and call `dispatchComplete()` when it should be marked as complete.  \n`dispatchComplete()` receives a single parameter which reports whether the subcommand completed successfully.\n\nHere's an example of a simulated asynchronous sub command:\n```ActionScript\npublic class DelayCommand extends AsyncCommand     {\n   protected var timer:Timer;\n   override public function execute():void {\n   \tsuper.execute();\n   \ttimer = new Timer(1000, 1);\n   \ttimer.addEventListener(TimerEvent.TIMER_COMPLETE, timerCompleteHandler);\n   \ttimer.start();\n   }\n   protected function timerCompleteHandler(event:TimerEvent):void {\n   \ttimer.removeEventListener(TimerEvent.TIMER_COMPLETE, timerCompleteHandler);\n   \ttimer = null;\n   \tdispatchComplete(true);\n   }\n}\n   \npublic class MyMacro extends SequenceMacro     {\n   override public function prepare():void {\n   \tadd(DelayCommand)\n   \tadd(OtherCommand)\n   \tregisterCompleteCallback(onComplete)\n   }\n   protected function onComplete(success):void {\n   \ttrace('all commands have been executed')\n   }\n}\n```\n\n### Atomic execution\n\nFor sequential macros, when the_ atomic_ property is set to **false** (it is **true** by default) and one of the sub commands dispatches a failure (using `dispatchComplete(false)`), subsequent sub commands will not be executed and the macro itself will dispatch failure.\n\nThis behaviour does not apply to parallel commands.\n\n## Building\n\nIn the **gradle** folder, make a copy of the _user.properties.eg_ file and call it _user.properties_\nEdit that file to provide values specific to your system\nUse the `gradlew` script to build the project\n\n## Contributing\n\nIf you want to contribute to the project refer to the [contributing document](CONTRIBUTING.md) for guidelines.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falebianco%2Frobotlegs-utilities-macrobot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falebianco%2Frobotlegs-utilities-macrobot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falebianco%2Frobotlegs-utilities-macrobot/lists"}