{"id":16853128,"url":"https://github.com/devxoul/asyncblockoperation","last_synced_at":"2025-08-31T19:44:31.586Z","repository":{"id":35244491,"uuid":"39504092","full_name":"devxoul/AsyncBlockOperation","owner":"devxoul","description":"NSOperation subclass for async block.","archived":false,"fork":false,"pushed_at":"2015-07-23T19:23:20.000Z","size":128,"stargazers_count":41,"open_issues_count":0,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T13:37:05.169Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","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/devxoul.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":"2015-07-22T12:10:41.000Z","updated_at":"2024-09-21T16:16:44.000Z","dependencies_parsed_at":"2022-09-16T20:01:12.709Z","dependency_job_id":null,"html_url":"https://github.com/devxoul/AsyncBlockOperation","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxoul%2FAsyncBlockOperation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxoul%2FAsyncBlockOperation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxoul%2FAsyncBlockOperation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxoul%2FAsyncBlockOperation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devxoul","download_url":"https://codeload.github.com/devxoul/AsyncBlockOperation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244189619,"owners_count":20412986,"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-10-13T13:49:50.518Z","updated_at":"2025-03-22T06:30:54.629Z","avatar_url":"https://github.com/devxoul.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"AsyncBlockOperation\n===================\n\n[![Build Status](https://travis-ci.org/devxoul/AsyncBlockOperation.svg)](https://travis-ci.org/devxoul/AsyncBlockOperation)\n[![CocoaPods](http://img.shields.io/cocoapods/v/AsyncBlockOperation.svg?style=flat)](https://cocoapods.org/pods/AsyncBlockOperation)\n\nNSOperation subclass for async block.\n\n* [x] Both compatible with Swift and Objective-C.\n* [x] Light-weight. (4KB source code. Oh my god.)\n* [x] Short-hand method extension `NSOperationQueue`.\n\n\nAt a Glance\n-----------\n\n**Swift**\n\n```swift\nimport AsyncBlockOperation\n\nlet operation = AsyncBlockOperation { op in\n    doSomeAsyncTaskWithCompletionBlock {\n        op.complete() // complete operation\n    }\n}\nqueue.addOperation(operation)\n```\n\n**Objective-C**\n\n```objc\n#import \u003cAsyncBlockOperation/AsyncBlockOperation.h\u003e\n\nAsyncBlockOperation *operation = [AsyncBlockOperation blockOperationWithBlock:^(AsyncBlockOperation *op) {\n    [self doSomeAsyncTaskWithCompletionBlock:^{\n        [op complete]; // complete operation\n    }];\n}];\n[queue addOperation:operation];\n```\n\n\nShort-hand Method Extension\n---------------------------\n\nAs `NSBlockOperation` does, `AsyncBlockOperation` supports `NSOperationQueue` extension to add async block operations quickly.\n\n**Swift**\n\n```swift\nqueue.addOperationWithAsyncBlock { op in\n    op.complete()\n}\n```\n\n**Objective-C**\n\n```objc\n[queue addOperationWithAsyncBlock:^(AsyncBlockOperation *op) {\n    [op complete];\n}];\n```\n\n\nFurther Reading\n---------------\n\nWanna get callback after all operations are done? Consider using [NSOperationQueue+CompletionBlock](https://github.com/devxoul/NSOperationQueue-CompletionBlock) which provides `completionHandler` for `NSOperationQueue`.\n\nFor example:\n\n```swift\nlet queue = NSOperationQueue()\nqueue.completionHandler = {\n    println(\"All images are loaded!\")\n}\nqueue.addOperationWithAsyncBlock { op in\n    loadImage(imageURL1) { image in\n        image.append(image)\n        op.complete()\n    }\n}\nqueue.addOperationWithAsyncBlock { op in\n    loadImage(imageURL2) { image in\n        image.append(image)\n        op.complete()\n    }\n}\n```\n\n\nInstallation\n------------\n\nI recommend you to use [CocoaPods](https://cocoapods.org), a dependency manager for Cocoa.\n\n**Podfile**\n\n```ruby\npod 'AsyncBlockOperation', '~\u003e 1.0'\n```\n\n\nLicense\n-------\n\n**AsyncBlockOperation** is under MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevxoul%2Fasyncblockoperation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevxoul%2Fasyncblockoperation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevxoul%2Fasyncblockoperation/lists"}