{"id":30719825,"url":"https://github.com/dankinsoid/vdchain","last_synced_at":"2025-09-03T10:42:19.418Z","repository":{"id":56925572,"uuid":"428341618","full_name":"dankinsoid/VDChain","owner":"dankinsoid","description":"Properties chaining","archived":false,"fork":false,"pushed_at":"2023-08-27T13:21:48.000Z","size":307,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-28T01:31:09.658Z","etag":null,"topics":[],"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/dankinsoid.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":"2021-11-15T16:33:40.000Z","updated_at":"2024-01-31T05:34:34.000Z","dependencies_parsed_at":"2022-08-21T06:20:10.892Z","dependency_job_id":null,"html_url":"https://github.com/dankinsoid/VDChain","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/dankinsoid/VDChain","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dankinsoid%2FVDChain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dankinsoid%2FVDChain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dankinsoid%2FVDChain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dankinsoid%2FVDChain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dankinsoid","download_url":"https://codeload.github.com/dankinsoid/VDChain/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dankinsoid%2FVDChain/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273431361,"owners_count":25104491,"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-09-03T02:00:09.631Z","response_time":76,"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":"2025-09-03T10:42:18.388Z","updated_at":"2025-09-03T10:42:19.378Z","avatar_url":"https://github.com/dankinsoid.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VDChain\n[![Version](https://img.shields.io/cocoapods/v/VDChain.svg?style=flat)](https://cocoapods.org/pods/VDChain)\n[![License](https://img.shields.io/cocoapods/l/VDChain.svg?style=flat)](https://cocoapods.org/pods/VDChain)\n[![Platform](https://img.shields.io/cocoapods/p/VDChain.svg?style=flat)](https://cocoapods.org/pods/VDChain)\n\n VDChain is a Swift library that harnesses the power of `@dynamicMemberLookup`, `KeyPath`, and `callAsFunction` to enable function chaining. This simplifies the modification of objects, allowing for cleaner and more concise code.\n\n## Features\n\n- Intuitive syntax for object modification\n- Improved readability and maintainability of Swift code\n- Great for both beginners and advanced Swift developers\n\n## Requirements\n\n- Swift 5.1+\n- iOS 11.0+\n- macOS 10.13+\n\n## Usage\n\nStart by importing SwiftChain in the files where you want to use it:\n\n```swift\nimport VDChain\n```\n\nYou can then use function chaining to modify your objects. For example:\n\n```swift\nlet label = UILabel().chain\n  .text(\"Text\")\n  .textColor(.red)\n  .font(.system(24))\n  .apply()\n```\n\nIn this example, `UILabel` properties `text`, `textColor`, and `font` are set through function chaining.\n\n## Chain Creation\n\nThere are three methods you can use to create a chain with VDChain:\n\n1. **Using the `.chain` property**: VDChain provides the `.chain` property on any `NSObject` type. You can also add this property to your own types by implementing the `Chainable` protocol. This protocol provides both static and instance properties, allowing you to call `.chain` on your types directly.\n\n   ```swift\n   let label = UILabel().chain\n     .text(\"Hello, World!\")\n     .textColor(.red)\n     .apply()\n   ```\n\n2. **Using the postfix operator `~`**: You can also create a chain using the `~` operator. This is a shorthand way to begin a chain on any value without calling the `.chain` property or implementing `Chainable` protocol.\n\n   ```swift\n   let button = UIButton()~\n     .title(\"Click me\")\n     .titleColor(.blue)\n     .apply()\n   ```\n\n3. **Using `EmptyChaining` or `TypeChaining`**: You can create an empty chain using the `EmptyChaining` class.\n\n   ```swift\n   let view = EmptyChaining(self).wrap()\n     .backgroundColor(.green)\n     .apply()\n   ```\n\nEvery chain method returns a `Chain\u003c...\u003e` object. To retrieve the original object from the chain, simply end your chain with the `apply()` method.\n\n### Type and Instance Chaining\n\nVDChain supports chaining on both types and instances. You can define a chain of methods on a type and later use this chain on an instance of that type:\n\n```swift\n// Create a chain on the UILabel type that sets the text color to black\nlet blackColorModifier = UILabel.chain\n  .textColor(.black)\n  .apply()\n\n// Use the chain on an instance of UILabel\nlet label = UILabel().chain\n  .modifier(blackColorModifier)\n  .apply()\n```\n\nThis allows you to define complex chains of modifications at the type level and easily apply them to instances as needed.\n\n## Real-world Usage Example\n\nTo see VDChain in action, check out my other library, [VDLayout](https://github.com/dankinsoid/VDLayout).\n\n## Installation\n1. [Swift Package Manager](https://github.com/apple/swift-package-manager)\n\nCreate a `Package.swift` file.\n```swift\n// swift-tools-version:5.0\nimport PackageDescription\n\nlet package = Package(\n  name: \"SomeProject\",\n  dependencies: [\n    .package(url: \"https://github.com/dankinsoid/VDChain.git\", from: \"3.6.0\")\n  ],\n  targets: [\n    .target(name: \"SomeProject\", dependencies: [\"VDChain\"])\n  ]\n)\n```\n```ruby\n$ swift build\n```\n\n2.  [CocoaPods](https://cocoapods.org)\n\nAdd the following line to your Podfile:\n```ruby\npod 'VDChain'\n```\nand run `pod update` from the podfile directory first.\n\n## Author\n\ndankinsoid, voidilov@gmail.com\n\n## License\n\nVDChain 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%2Fdankinsoid%2Fvdchain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdankinsoid%2Fvdchain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdankinsoid%2Fvdchain/lists"}