{"id":15787171,"url":"https://github.com/fmo91/fotask","last_synced_at":"2025-03-14T11:31:34.793Z","repository":{"id":56910649,"uuid":"81281729","full_name":"fmo91/FOTask","owner":"fmo91","description":"Object oriented Swift tasks microframework with concurrency and composition 🎉","archived":false,"fork":false,"pushed_at":"2017-02-24T15:08:40.000Z","size":33,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-11T21:45:15.384Z","etag":null,"topics":["concurrency","object-oriented","swift","tasks"],"latest_commit_sha":null,"homepage":null,"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/fmo91.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-02-08T03:09:40.000Z","updated_at":"2018-08-19T12:19:00.000Z","dependencies_parsed_at":"2022-08-20T20:20:35.055Z","dependency_job_id":null,"html_url":"https://github.com/fmo91/FOTask","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fmo91%2FFOTask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fmo91%2FFOTask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fmo91%2FFOTask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fmo91%2FFOTask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fmo91","download_url":"https://codeload.github.com/fmo91/FOTask/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243569657,"owners_count":20312477,"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":["concurrency","object-oriented","swift","tasks"],"created_at":"2024-10-04T21:06:02.714Z","updated_at":"2025-03-14T11:31:31.702Z","avatar_url":"https://github.com/fmo91.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FOTask\n\n[![CI Status](http://img.shields.io/travis/fmo91/FOTask.svg?style=flat)](https://travis-ci.org/fmo91/FOTask)\n[![Version](https://img.shields.io/cocoapods/v/FOTask.svg?style=flat)](http://cocoapods.org/pods/FOTask)\n[![License](https://img.shields.io/cocoapods/l/FOTask.svg?style=flat)](http://cocoapods.org/pods/FOTask)\n[![Platform](https://img.shields.io/cocoapods/p/FOTask.svg?style=flat)](http://cocoapods.org/pods/FOTask)\n\n## Introduction\n\nFOTask is a microframework (less than 100 LOCs), with a single objective in mind: **separation of concerns**. \nEvery subclass of `Task` executes an action. \n`Task`s can be composed in more complex `Task`s, or parallelized without effort.\n\n## Example usage\n\n**Suclassing Task:**\n\n```swift\nfinal class GetUserTask: Task\u003cInt, User\u003e {\n\toverride func perform(_ input: Int, onSuccess: @escaping (User) -\u003e Void, onError: @escaping (Error) -\u003e Void) {\n\t\tApiClient(\"https://somecoolapi.com/users/\\(input)\", .get,\n        \tonSuccess: { (json: Any) in\n            \tonSuccess(User(json: json))\n            }, \n            onError: { (error: Error) in\n            \tonError(error)\n            }\n        ) \n    }\n}\n```\n\n**Using Task:**\n\n```swift\nlet getUserTask = GetUserTask()\n\ngetUserTask.perform(3,\n\tonSuccess: { (user: User) in\n    \tprint(user.name)\n    },\n    onError: { (error: Error) in\n    \tprint(\"An error ocurred.\")\n    }\n)\n```\n\n**Composing Tasks:**\n\n```swift\nlet getUserWithIDTask = GetUserTask()\nlet getPostsFromUserTask = GetPostsFromUserTask()\n\nlet getPostsFromUserID = getUserWithIDTask =\u003e getPostsFromUserTask\n\ngetPostsFromUserID.perform(3,\n\tonSuccess: { (posts: [Post]) in\n    \tprint(posts.count)\n    },\n    onError: { (error: Error) in\n    \tprint(\"An error ocurred.\")\n    }\n)\n```\n\n**Parallelize Tasks**\n\n```swift\nlet getALotOfUserNames = Task.parallel(\n    [\n        GetUserName(),\n        GetUserName(),\n        GetUserName(),\n        GetUserName(),\n        GetUserName(),\n        GetUserName(),\n        GetUserName(),\n        GetUserName(),\n        GetUserName()\n    ],\n    reduce: { (userNames: [String]) -\u003e [String] in\n        return userNames\n    }\n)\n\ngetALotOfUserNames.perform(Void(),\n    onSuccess: { userNames in\n        print(userNames)\n    },\n    onError: { error in\n        print(\"An Error!\")\n    }\n)\n```\n\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## Requirements\n\n* iOS 8.0 or above.\n* Swift 3.0 or above.\n\n## Installation\n\nFOTask is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod \"FOTask\"\n```\n\n## Coming soon\n\n* An explanatory Medium post\n* More documentation\n* More examples\n* More functional features?\n\n## Author\n\nfmo91, ortizfernandomartin@gmail.com\n\n## License\n\nFOTask 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%2Ffmo91%2Ffotask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffmo91%2Ffotask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffmo91%2Ffotask/lists"}