{"id":1841,"url":"https://github.com/MaximKotliar/Bindy","last_synced_at":"2025-08-02T04:32:40.947Z","repository":{"id":45540748,"uuid":"108915492","full_name":"MaximKotliar/Bindy","owner":"MaximKotliar","description":"Simple, lightweight swift bindings ","archived":false,"fork":false,"pushed_at":"2021-12-09T13:34:55.000Z","size":240,"stargazers_count":25,"open_issues_count":6,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-18T10:30:48.726Z","etag":null,"topics":[],"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/MaximKotliar.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-10-30T22:30:01.000Z","updated_at":"2023-07-27T16:35:58.000Z","dependencies_parsed_at":"2022-09-21T18:10:53.696Z","dependency_job_id":null,"html_url":"https://github.com/MaximKotliar/Bindy","commit_stats":null,"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"purl":"pkg:github/MaximKotliar/Bindy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaximKotliar%2FBindy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaximKotliar%2FBindy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaximKotliar%2FBindy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaximKotliar%2FBindy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MaximKotliar","download_url":"https://codeload.github.com/MaximKotliar/Bindy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaximKotliar%2FBindy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268334618,"owners_count":24233793,"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-08-02T02:00:12.353Z","response_time":74,"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":[],"created_at":"2024-01-05T20:15:57.066Z","updated_at":"2025-08-02T04:32:40.581Z","avatar_url":"https://github.com/MaximKotliar.png","language":"Swift","funding_links":[],"categories":["Reactive Programming"],"sub_categories":["Prototyping","Other Parsing"],"readme":"[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/vsouza/awesome-ios)\n[![Build status][image-1]][1]\n[![Version][image-2]][2]\n[![License][image-3]][3]\n[![Platform][image-4]][4]\n\n# Bindy\nJust a simple bindings.\n\n## Installation\n\nAdd\n`pod 'Bindy'`\n\nto your podfile, and run\n`pod install`\n\nSPM is supported too.\n\n## Usage\nFor now, Bindy has a couple of basic types\n\n* Signal - allows triggering a callback when some signal received.\n* Observable - allows observing changing of value.\n* ObservableArray - conforms to MutableCollection protocol, so you can work with it like with a regular array: subscript index, replace objects, map, enumerate, etc... Also, ObservableArray has `updates` signal, which will notify you about any changes in the array, such as insert, replace, delete.\n\n### Observables Sample (updated with property wrappers)\n\n```swift\n@Observable var firstname = \"Salvador\"\n@Observable var age = 54\n\nfunc setupBindings() {\n    $age.bind(self) { [unowned self] newAge in\n            print(\"Happy \\(newAge) birthday, \\(firstname)\")\n    }\n    age = 55\n}\n```\n\nDon't forget always use `[unowned owner]` in closure to prevent the retain cycle.\n\n### Signal and Array Sample\n\n```swift\nlet messages: ObservableArray\u003cMessage\u003e = []\nlet newMessage = Signal\u003cMessage\u003e()\n    \nfunc setupBindings() {\n    newMessage.bind(self) { [unowned self] message in\n            self.messages.append(message)\n    }\n    \n    messages.updates.bind(self) { [unowned tableView] updates in\n            self.tableView.pefrom(updates: updates)     \n       }\n}\n       \nfunc handleDidRecieveMessage(_ message: Message) {\n     newMessage.send(message)      \n    }\n}\n```\n\nYou don't need to remove binding manually if you don't want. When the object that you pass as owner in `bind(_ owner: AnyObject...` method deallocates, corresponding bindings will clean. However, if you want to unbind manually, just call `unbind(_ owner: AnyObject)`.\nBindy has an extension for tableView for performing updates `tableView.perform(updates:...`\n\nAlso, observables have a method `observe(_ owner: AnyObject...`, it works like `bind`, but triggers callback immediately, this may be more comfortable in some situations.\n\n### Transformations\n\nIf you want to receive events with transformed type, you can use `transform` function on Observables like: \n\n```swift\nlet speed = Observable(20)\nlazy var speedString = speed.transform { \"\\($0)km/h\" }\n    \nfunc setupBindings() {\n    speedString.observe(self) { [unowned self] speedString in\n        // speedString = \"20km/h\"\n            self.speedLabel.text = speedString\n        }\n}\n```\n\n### Combinations\n\nYou can combine two Observable types with `combined(with: ..., transform: ...)` function like: \n\n```swift\nlet firstname = Observable(\"Maxim\")\nlet lastname = Observable(\"Kotliar\")\nlet age = Observable(24)\n\nlazy var fullName = firstname\n            .combined(with: lastname) { \"name: \\($0) \\($1)\" }\n            .combined(with: age) { \"\\($0), age: \\($1)\" }\n\nfunc setupBindings() {\n    userInfo.observe(self) { [unowned self] info in\n            // info = \"name: Maxim Kotliar, age:24\"\n            self.userInfoLabel.text = info\n        }\n}\n```\n\nFor `Observable\u003cBool\u003e` combinations Bindy have more convenient operators `\u0026\u0026` and `||`, so you can combine `Observable\u003cBool\u003e` like regular Bool, also you can invert it with `!`:\n\n```swift\nlet isPremiumPurchased = Observable(true)\nlet isInTrialPeriodEnded = Observable(false)\nlet isAdsShowForced = Observable(false)\n\nlazy var shouldShowAds = isAdsShowForced || !isPremiumPurchased \u0026\u0026 isInTrialPeriodEnded\n```\n\n### KVO support\n\nBindy supports KVO, so you can create `Observable` from any KVO capable property with easy subscript syntax like:\n\n```swift\nlet textField = UITextField()\nlet text = textField[\\.text] // type will be Observable\u003cString?\u003e\n\ntext.observe(self) { newText in\n    print(newText)\n}\n```\n\n### Old value\n\nFor any `Observable` type you can receive old value in closure, just pass two parameters to binding closure, first one will be an old value, the second one – new value: \n\n```swift\nlet observableString = Observable(\"test\")\n\nobservableString.bind(self) { oldString, newString in\n    print(\"String changed from \\(oldString) to \\(newString)\")\n}\n```\n\n### High order functions\n\nBindy contains some high order functions:\n- `map` - applies on any type, behavior similar to a swift map.\n- `flatMap` - applies on Observable with optional type, returns Signal with non-optional type.\n- `compactMap` - applies on Observable with Collection inside, behavior similar to a swift version of the function.\n- `reduce` - applies on Observable with Collection inside, behavior similar to a swift version of the function.\n- `filter` - applies on Observable with Collection inside, behavior similar to a swift version of the function.\n\n[1]:    https://travis-ci.org/MaximKotliar/Bindy\n[2]:    http://cocoapods.org/pods/Bindy\n[3]:    http://cocoapods.org/pods/Bindy\n[4]:    http://cocoapods.org/pods/Bindy\n\n[image-1]:    https://img.shields.io/travis/MaximKotliar/Bindy/master.svg?style=flat-square\n[image-2]:    https://img.shields.io/cocoapods/v/Bindy.svg?style=flat-square\n[image-3]:    https://img.shields.io/cocoapods/l/Bindy.svg?style=flat-square\n[image-4]:    https://img.shields.io/cocoapods/p/Bindy.svg?style=flat-square\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMaximKotliar%2FBindy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMaximKotliar%2FBindy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMaximKotliar%2FBindy/lists"}