{"id":1128,"url":"https://github.com/ulrikdamm/Forbind","last_synced_at":"2025-07-30T20:32:31.910Z","repository":{"id":29285323,"uuid":"32818071","full_name":"ulrikdamm/Forbind","owner":"ulrikdamm","description":"Functional chaining and promises in Swift","archived":false,"fork":false,"pushed_at":"2017-05-03T13:12:20.000Z","size":142,"stargazers_count":45,"open_issues_count":0,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-26T23:22:02.212Z","etag":null,"topics":["async","binding","monads","promise","result","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/ulrikdamm.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-03-24T18:45:19.000Z","updated_at":"2022-09-01T20:22:20.000Z","dependencies_parsed_at":"2022-09-06T12:52:23.386Z","dependency_job_id":null,"html_url":"https://github.com/ulrikdamm/Forbind","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ulrikdamm%2FForbind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ulrikdamm%2FForbind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ulrikdamm%2FForbind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ulrikdamm%2FForbind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ulrikdamm","download_url":"https://codeload.github.com/ulrikdamm/Forbind/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228187535,"owners_count":17882322,"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":["async","binding","monads","promise","result","swift"],"created_at":"2024-01-05T20:15:39.499Z","updated_at":"2024-12-04T20:31:00.685Z","avatar_url":"https://github.com/ulrikdamm.png","language":"Swift","funding_links":[],"categories":["Functional Programming","Libs"],"sub_categories":["Getting Started","Other free courses","Linter","Events"],"readme":"# Forbind\n\nFunctional chaining and promises in Swift\n\nNote: still in an experimental state. Everything could change. I would love some feedback on this. Write to [@ulrikdamm](https://twitter.com/ulrikdamm) on Twitter.\n\n# What is it\n\nBind local or async expressions together functionally, all error handling taken care of for you:\n\n```swift\nfunc getUser(id : String) -\u003e Promise\u003cResult\u003cUser\u003e\u003e {\n\tlet data = NSURL(string: id)\n\t\t=\u003e { NSURLRequest(URL: $0) }\n\t\t=\u003e NSURLConnection.sendRequest(.mainQueue())\n\t\t=\u003e { response, data in data }\n\t\n\treturn data\n\t\t=\u003e NSJSONSerialization.toJSON(options: nil)\n\t\t=\u003e { $0.dictionaryValue }\n\t\t=\u003e User.fromJSON\n}\n```\n\n• Bind operations together with =\u003e\n\n• No error handling inside your logic\n\n• Transparent async calls\n\n• No if-lets\n\n• Combine inputs with ++\n\nFor more details, read my [Blog post](http://ufd.dk/blog/Binds-and-promises-with-Forbind).\n\n## New in 1.1\n\n• ResultPromise and OptionalPromise has been replaced with Promise\u003cResult\u003cT\u003e\u003e and Promise\u003cT?\u003e. Still works the same.\n\n• You can use the bind operator to map over lists of promises!\n\n```swift\nlet user = User(name: \"Ulrik\")\nlet names = user.loadFriends() =\u003e { $0.name } // [Promise\u003cString\u003e]\n```\n\n• And you can also filter and reduce with filterp and reducep:\n\n```swift\nlet someNames = filterp(names) { $0 != \"Peter\" } // Promise\u003c[String]\u003e\n```\n\n• The NSJSONSerialization extension now returns a JSONResult, which is either a Dictionary or Array.\n\n# Get started\n\nYou can add Forbind to your project using [CocoaPods](https://cocoapods.org). Just add it to your Podfile:\n\n```ruby\nuse_frameworks!\n\npod 'Forbind', '~\u003e 1.1'\npod 'ForbindExtensions', :git =\u003e 'https://github.com/ulrikdamm/Forbind'\n```\n\n(You need the ```use_frameworks!``` since that feature of CocoaPods is still in beta. ForbindExtensions are optional)\n\nOr you can add it using [Carthage](https://github.com/Carthage/Carthage) by adding this to your cartfile:\n\n```\ngithub \"ulrikdamm/Forbind\" ~\u003e 1.0\n```\n\nThis will add both Forbind.framework and ForbindExtensions.framework, which you can drag into your Xcode project.\n\nThen in your files just import Forbind and optionally ForbindExtensions\n\n```\nimport Forbind\nimport ForbindExtensions\n```\n\nThe Forbind library is the bind operator (```=\u003e```) and the combine operator (```++```), along with the Result enum and Promise classes.\n\nForbindExtensions are extensions to Foundation and UIKit for working better with Forbind, by, for example, returning a promise instead of using a completion block. The ForbindExtensions are still a work in progress, so you might want to make your own extensions instead. In this case, just only include the Forbind framework.\n\n# What is the state of the project?\n\nIt’s still very experimental, so I would love some feedback on it. I wouldn’t recommend relying on this for product code yet. If you have a good idea, or just questions, submit a pull request or contact me at [@ulrikdamm](https://twitter.com/ulrikdamm) on Twitter.\n\nThings that still needs to be considered:\n\n• General direction of the project (are there some fundamental flaws?)\n\n• Promise cancellation (support for cancelling an async operation if a promise is deallocated)\n\n• Handling of dispatch queues (currently promise callbacks are run on the same queue as the operation finished on)\n\n• More extensions for common UIKit/AppKit/Foundation methods to use Promise and Result instead of NSErrorPointer and completion blocks.\n\n• \"Expression was too complex to be solved in reasonable time\" for big expressions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fulrikdamm%2FForbind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fulrikdamm%2FForbind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fulrikdamm%2FForbind/lists"}