{"id":29278253,"url":"https://github.com/incetro/lagoon","last_synced_at":"2026-05-15T20:04:01.272Z","repository":{"id":56919575,"uuid":"96993160","full_name":"Incetro/Lagoon","owner":"Incetro","description":"The beautiful way to chain your services logic","archived":false,"fork":false,"pushed_at":"2023-11-01T16:35:00.000Z","size":297,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-04T22:49:00.853Z","etag":null,"topics":["ios","lagoon","macos","nsoperation","nsoperationqueue","operations","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/Incetro.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":"2017-07-12T10:02:40.000Z","updated_at":"2023-11-01T16:35:04.000Z","dependencies_parsed_at":"2022-08-21T04:20:14.274Z","dependency_job_id":null,"html_url":"https://github.com/Incetro/Lagoon","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/Incetro/Lagoon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Incetro%2FLagoon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Incetro%2FLagoon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Incetro%2FLagoon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Incetro%2FLagoon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Incetro","download_url":"https://codeload.github.com/Incetro/Lagoon/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Incetro%2FLagoon/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267867804,"owners_count":24157356,"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","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ios","lagoon","macos","nsoperation","nsoperationqueue","operations","swift"],"created_at":"2025-07-05T11:01:49.198Z","updated_at":"2026-05-15T20:03:56.228Z","avatar_url":"https://github.com/Incetro.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](lagoon.png)\n\n[![Build Status](https://travis-ci.org/incetro/Lagoon.svg?branch=master)](https://travis-ci.org/incetro/Lagoon)\n[![CocoaPods](https://img.shields.io/cocoapods/v/Lagoon.svg)](https://img.shields.io/cocoapods/v/Lagoon.svg)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![GitHub license](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://raw.githubusercontent.com/incetro/Lagoon/master/LICENSE.md)\n[![Platforms](https://img.shields.io/cocoapods/p/Lagoon.svg)](https://cocoapods.org/pods/Lagoon)\n\nLagoon is a framework written in Swift that makes it easy for you to organize your service layer\n\n- [Features](#features)\n- [Usage](#usage)\n- [Requirements](#requirements)\n- [Communication](#communication)\n- [Installation](#installation)\n- [Author](#author)\n- [License](#license)\n\n## Features\n- [x] Asynchronous operations\n- [x] SOLID out of the box\n- [x] Very simple writing unit tests\n- [x] Reusable business logic\n- [x] Generics\n\n## Usage\n### Look at the simple example\nHere we convert our string to number, increment and decrement it, multiply and divide by digits.\nLet's create example operations:\n```swift\n\n/// Convert String to Int\nclass ConvertOperation: ChainableOperationBase\u003cString, Int\u003e {\n    \n    override func process(inputData: String, success: (Int) -\u003e (), failure: (Error) -\u003e ()) {\n        if let result = Int(inputData) {\n            success(result)\n        } else {\n            failure(NSError(domain: \"com.incetro.Lagoon.Example\", code: 1, userInfo: nil))\n        }\n    }\n}\n\n/// Increment the given number\nclass IncrementOperation: ChainableOperationBase\u003cInt, Int\u003e {\n    \n    override func process(inputData: Int, success: (Int) -\u003e (), failure: (Error) -\u003e ()) {\n        success(inputData + 1)\n    }\n}\n\n/// Decrement the given number\nclass DecrementOperation: ChainableOperationBase\u003cInt, Int\u003e {\n    \n    override func process(inputData: Int, success: (Int) -\u003e (), failure: (Error) -\u003e ()) {\n        success(inputData - 1)\n    }\n}\n\n/// Multiply the given number\nclass MultiplicationOperation: ChainableOperationBase\u003cInt, Int\u003e {\n    \n    let mult: Int\n    \n    init(with mult: Int) {\n        self.mult = mult\n    }\n    \n    override func process(inputData: Int, success: (Int) -\u003e (), failure: (Error) -\u003e ()) {\n        success(inputData * self.mult)\n    }\n}\n\n/// Make array of digits from the given number\nclass ArrayOperation: ChainableOperationBase\u003cInt, [Int]\u003e {\n    \n    override func process(inputData: Int, success: ([Int]) -\u003e (), failure: (Error) -\u003e ()) {\n        \n        var result: [Int] = []\n        var number = inputData\n        \n        while number \u003e 0 {\n            result.append(number % 10)\n            number = number / 10\n        }\n        \n        success(result.reversed())\n    }\n}\n```\nAnd make chain ```convert -\u003e increment -\u003e decrement -\u003e multiplication -\u003e array```\n```swift\nlet strings = [\"123\", \"4\", \"56a\", \"a\", \"\"]\n        \nfor string in strings {\n            \n    let convert   = ConvertOperation()\n    let increment = IncrementOperation()\n    let decrement = DecrementOperation()\n    let mult      = MultiplicationOperation(with: 125)\n    let array     = ArrayOperation()\n            \n    /// Create chain\n    let operations = [convert, increment, decrement, mult, array]\n            \n    /// We expect Int array as output type\n    let compoundOperation = CompoundOperation.default(withOutputDataType: [Int].self)\n    \n    /// Setup compound operation\n    compoundOperation.configure(withChainableOperations: operations, inputData: string, success: { result in\n        print(result)\n    }, failure: { error in\n        print(error.localizedDescription)\n    })\n    \n    /// Start it!\n    Lagoon.add(operation: compoundOperation)\n}\n```\n## Advanced usage\nOkay, how can you use it in the real projects? Look at this.\n```swift\n// MARK: - RequestDataSigningOperation\nclass RequestDataSigningOperation: ChainableOperationBase\u003cRequestDataModel, RequestDataModel\u003e {\n    \n    private let requestSigner: RequestDataSigner\n    \n    init(withRequestSigner requestSigner: RequestDataSigner) {\n        self.requestSigner = requestSigner\n    }\n    \n    override func process(inputData: RequestDataModel, success: (RequestDataModel) -\u003e (), failure: (Error) -\u003e ()) {\n        let signedRequestDataModel = requestSigner.signRequestDataModel(inputData)\n        success(signedRequestDataModel)\n    }\n}\n\n// MARK: - RequestConfigurationOperation\nclass RequestConfigurationOperation: ChainableOperationBase\u003cRequestDataModel, URLRequest\u003e {\n    \n    private let requestConfigurator: RequestConfigurator\n    private let method: HTTPMethod\n    private let serviceName: String?\n    private let urlParameters: [String]\n    private let queryType: QueryType\n    \n    init(configurator: RequestConfigurator, method: HTTPMethod, type: QueryType, serviceName: String?, urlParameters: [String]) {\n        self.method = method\n        self.queryType = type\n        self.serviceName = serviceName\n        self.urlParameters = urlParameters\n        self.requestConfigurator  = configurator\n    }\n    \n    // MARK: - ChainableOperationBase\n    \n    override func process(inputData: RequestDataModel, success: (URLRequest) -\u003e (), failure: (Error) -\u003e ()) {\n        \n        let request = requestConfigurator.createRequest(withMethod:       self.method,\n                                                        type:             self.queryType,\n                                                        serviceName:      self.serviceName,\n                                                        urlParameters:    self.urlParameters,\n                                                        requestDataModel: inputData)\n        \n        success(request)\n    }\n}\n\n/// And other operations...\n/// Then use it to make network chain\n\nlet operations = [\n    requestDataSigningOperation,\n    requestConfigurationOperation,\n    networkRequestOperation,\n    deserializationOperation,\n    validationOperation,\n    responseCachingOperation,\n    responseMappingOperation\n]\n\nlet compoundOperation = CompoundOperation.default(withOutputDataType: User.self)\ncompoundOperation.maxConcurrentOperationCount = 1\ncompoundOperation.configure(withChainableOperations: operations, inputData: inputData, success: success, failure: failure)\nLagoon.add(operation: compoundOperation)\n```\n## Requirements\n- iOS 8.0+ / macOS 10.9+\n- Xcode 8.1, 8.2, 8.3, and 9.0\n- Swift 3.0, 3.1, 3.2, and 4.0\n\n## Communication\n\n- If you **found a bug**, open an issue.\n- If you **have a feature request**, open an issue.\n- If you **want to contribute**, submit a pull request.\n\n## Installation\n\n### CocoaPods\n\n[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:\n\n```bash\n$ gem install cocoapods\n```\n\nTo integrate Lagoon into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nuse_frameworks!\n\ntarget \"\u003cYour Target Name\u003e\" do\n    pod \"Lagoon\"\nend\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n### Manually\n\nIf you prefer not to use any dependency managers, you can integrate Lagoon into your project manually.\n\n#### Embedded Framework\n\n- Open up Terminal, `cd` into your top-level project directory, and run the following command \"if\" your project is not initialized as a git repository:\n\n  ```bash\n  $ git init\n  ```\n\n- Add Lagoon as a git [submodule](http://git-scm.com/docs/git-submodule) by running the following command:\n\n  ```bash\n  $ git submodule add https://github.com/incetro/Lagoon.git\n  ```\n\n- Open the new `Lagoon` folder, and drag the `Lagoon.xcodeproj` into the Project Navigator of your application's Xcode project.\n\n    \u003e It should appear nested underneath your application's blue project icon. Whether it is above or below all the other Xcode groups does not matter.\n\n- Select the `Lagoon.xcodeproj` in the Project Navigator and verify the deployment target matches that of your application target.\n- Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the \"Targets\" heading in the sidebar.\n- In the tab bar at the top of that window, open the \"General\" panel.\n- Click on the `+` button under the \"Embedded Binaries\" section.\n- You will see two different `Lagoon.xcodeproj` folders each with two different versions of the `Lagoon.framework` nested inside a `Products` folder.\n\n    \u003e It does not matter which `Products` folder you choose from, but it does matter whether you choose the top or bottom `Lagoon.framework`.\n\n- Select the top `Lagoon.framework` for iOS and the bottom one for OS X.\n\n    \u003e You can verify which one you selected by inspecting the build log for your project. The build target for `Lagoon` will be listed as either `Lagoon iOS`, `Lagoon macOS`.\n\n- And that's it!\n\n  \u003e The `Lagoon.framework` is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.\n  \n## Author\n\nincetro, incetro@ya.ru. Inspired by [COOperation](https://github.com/strongself/COOperation)\n\n## License\n\nLagoon is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fincetro%2Flagoon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fincetro%2Flagoon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fincetro%2Flagoon/lists"}