{"id":13744888,"url":"https://github.com/jeremyruppel/as3-operations","last_synced_at":"2026-01-05T05:33:23.832Z","repository":{"id":1323531,"uuid":"1268752","full_name":"jeremyruppel/as3-operations","owner":"jeremyruppel","description":"Async operation contracts and helpers for ActionScript 3","archived":false,"fork":false,"pushed_at":"2012-01-25T17:39:09.000Z","size":8341,"stargazers_count":22,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-28T22:18:52.203Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/jeremyruppel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-01-18T21:51:21.000Z","updated_at":"2023-07-25T19:11:38.000Z","dependencies_parsed_at":"2022-08-16T13:05:21.444Z","dependency_job_id":null,"html_url":"https://github.com/jeremyruppel/as3-operations","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeremyruppel%2Fas3-operations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeremyruppel%2Fas3-operations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeremyruppel%2Fas3-operations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeremyruppel%2Fas3-operations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeremyruppel","download_url":"https://codeload.github.com/jeremyruppel/as3-operations/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245128130,"owners_count":20565206,"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:17.927Z","updated_at":"2026-01-05T05:33:23.798Z","avatar_url":"https://github.com/jeremyruppel.png","language":"ActionScript","funding_links":[],"categories":["Unsorted"],"sub_categories":["Other API"],"readme":"AS3 Operations\n==============\n\n**as3-operations** is a set of async operation contracts and helpers for ActionScript 3.\nThe package utilizes Robert Penner's excellent [as3-signals][as3-signals] library for its\ncallback mechanism. Signals are a convenient choice because they are fast and can be easily\nand neatly cleaned up after an operation has finished.\n\nUsage Overview\n--------------\n\nFor many asynchronous operations, we typically only need to know whether the operation has\nsucceeded or failed, and with what result. The `IOperation` contract describes this behavior,\nproviding only a `succeeded` signal, a `failed` signal, and a `call` method that should be used\nto initiate the operation.\n\nA simple asynchronous load operation could look like this:\n\n\tclass LoadImageOperation extends Operation\n\t{\n\t\tpublic function LoadImageOperation( url : String )\n\t\t{\n\t\t\tsuper( DisplayObject, String, function( operation : Operation ) : void\n\t\t\t{\n\t\t\t\tvar loader : Loader = new Loader( );\n\t\t\t\t\n\t\t\t\tvar request : URLRequest = new URLRequest( url );\n\t\t\t\t\n\t\t\t\tloader.contentLoaderInfo.addEventListener( Event.COMPLETE, function( event : Event ) : void\n\t\t\t\t{\n\t\t\t\t\toperation.succeed( event.target.content );\n\t\t\t\t} );\n\t\t\t\t\n\t\t\t\tloader.contentLoaderInfo.addEventListener( IOErrorEvent.IO_ERROR, function( event : Event ) : void\n\t\t\t\t{\n\t\t\t\t\toperation.fail( 'Image at url \"' + url '\" could not be found' );\n\t\t\t\t} );\n\t\t\t\t\n\t\t\t\tloader.contentLoaderInfo.addEventListener( SecurityErrorEvent.SECURITY_ERROR, function( event : Event ) : void\n\t\t\t\t{\n\t\t\t\t\toperation.fail( 'Image could not be loaded because the policy file was missing or something' );\n\t\t\t\t} );\n\t\t\t\t\n\t\t\t\tloader.load( request );\n\t\t\t} );\n\t\t}\n\t}\n\nThis operation translates the loader's several different events into either success or failure. The operation\ncan then be used like this:\n\n\tvar operation : IOperation = new LoadImageOperation( 'my-image.jpg' );\n\t\n\toperation.succeeded.add( function( image : DisplayObject ) : void\n\t{\n\t\ttrace( image );\n\t} );\n\t\n\toperation.failed.add( function( message : String ) : void\n\t{\n\t\ttrace( 'Failure!: ' + message );\n\t} );\n\t\n\toperation.call( );\n\nOperation Groups\n----------------\n\nThe **as3-operations** package comes with two simple implementation of operation groups: `OperationGroup` and\n`OperationQueue`. The biggest difference between the two is that an `OperationGroup` executes all of its sub-operations\nat the same time while an `OperationQueue` executes them single-file. Each group will, by default, succeed only if \nall of its sub-operations succeed, though this can be configured through the group's constructor. Both groups also\nallow chaining through their `add` method so multiple operations can be added in-line if you wish.\n\n**Note:** Since operation groups can have any number of sub-operations (including other operation groups), the succeeded\nand failed handlers for groups do not receive a payload. To handle the success or failure of each sub-operation, attach\nhandlers to the sub-operation directly.\n\n\tvar group : IOperationGroup = new OperationGroup( );\n\t\n\tvar config : IOperation = new LoadConfigOperation( );\n\t\n\tvar assets : IOperation = new LoadAssetsOperation( );\n\t\n\tconfig.succeeded.add( function( xml : XML ) : void\n\t{\n\t\t// do something with the config xml...\n\t} );\n\t\n\tgroup.succeeded.add( function( ) : void\n\t{\n\t\ttrace( 'all assets have finished loading' );\n\t} );\n\t\n\tgroup.add( config ).add( assets ).call( );\n\nOperation Chains\n----------------\n\n**as3-operations** comes with a simple `OperationChain` implementation, which behaves a lot like an `OperationQueue`,\nexcept that the payload from each operation that finishes is passed to the next operation in the queue, with the final\npayload yielded to the success handler of the chain. To do this cleanly, operations are generated from `IOperationFactory`\nimplementations. See the tests and support classes for examples of how you could implement this yourself.\n\n[as3-signals]: https://github.com/robertpenner/as3-signals \"as3-signals\"","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeremyruppel%2Fas3-operations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeremyruppel%2Fas3-operations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeremyruppel%2Fas3-operations/lists"}