khuong291 / Binder

🦁"Hello World" <-> [🏷, 🏷, 🏷, 🏷]

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Version Carthage compatible Swift 4.0 Platform License

A lightweight data binding for components on iOS

About

A lightweight data binding for components on iOS, easy to use and does not have retain cycle.

Contributing

  1. Fork project
  2. Checkout master branch
  3. Create Feature branch off of the master branch
  4. Create awesome feature/enhancement/bug-fix
  5. Optionally create Issue to discuss feature
  6. Submit pull request from your Feature branch to Binder's master branch

Installation

use_frameworks!

pod 'Binder'

Add Binder to you Cartfile

github "khuong291/Binder"

Install using

carthage update --platform ios

Manually

  1. Download and drop /Binder folder in your project.
  2. You're done!

Getting started

Create a Binder object:

private let colorBinder: Binder<UIColor, ViewBindingType> = Binder(value: .white, type: .backgroundColor)
private let textBinder: Binder<String, LabelBindingType> = Binder(value: "Hello", type: .text)

You can bind many components as you want:

colorBinder <-> [view1, view2, view3, view4]
textBinder <-> label1 <-> label2 <-> label3 <-> label4

Change the binder value:

colorBinder.value = .green
textBinder.value = "Green Color"

If you want to avoid retain cycle, you should remove binder objects:

deinit {
    colorBinder.remove()
    textBinder.remove()
}

And that's it ;)

Requirements

  • iOS 9.0+
  • Xcode 8.0+
  • Swift 3.0+

Author

Khuong Pham

License

Binder is released under the MIT license.
See LICENSE for details.

About

🦁"Hello World" <-> [🏷, 🏷, 🏷, 🏷]

License:MIT License


Languages

Language:Swift 90.4%Language:Ruby 6.0%Language:Objective-C 3.6%