All Projects → electricbolt → bindkit

electricbolt / bindkit

Licence: BSD-2-Clause license
Two-way data binding framework for iOS. Only one API to learn.

Programming Languages

objective c
16641 projects - #2 most used programming language
swift
15916 projects

Projects that are alternatives of or similar to bindkit

bound
Data-binding made easy
Stars: ✭ 21 (+61.54%)
Mutual labels:  reactive, binding
observable ish
Observable state and events for browser and Flutter.
Stars: ✭ 26 (+100%)
Mutual labels:  reactive, binding
Fritz2
Easily build reactive web-apps in Kotlin based on flows and coroutines.
Stars: ✭ 308 (+2269.23%)
Mutual labels:  reactive, binding
WpfExtensions
Some syntactic sugar for Wpf development.
Stars: ✭ 128 (+884.62%)
Mutual labels:  reactive, binding
Rxrealmdatasources
An easy way to bind an RxRealm observable to a table or collection view
Stars: ✭ 154 (+1084.62%)
Mutual labels:  reactive, binding
unicorn-net
WIP .NET binding/wrapper for the Unicorn engine written in C#
Stars: ✭ 44 (+238.46%)
Mutual labels:  binding
muon-java
Muon Core for the JVM. APIs and Microservices taken to the next level
Stars: ✭ 18 (+38.46%)
Mutual labels:  reactive
bassdrum
reactive, type safe components with preact and rxjs.
Stars: ✭ 44 (+238.46%)
Mutual labels:  reactive
lila-ws
Lichess' websocket server
Stars: ✭ 99 (+661.54%)
Mutual labels:  reactive
go-tree-sitter
Golang bindings for tree-sitter https://github.com/tree-sitter/tree-sitter
Stars: ✭ 137 (+953.85%)
Mutual labels:  binding
cl-gserver
Actor framework featuring actors and agents for easy access to state and asynchronous operations.
Stars: ✭ 121 (+830.77%)
Mutual labels:  reactive
meteor-pg
Use PostgreSQL reactively in Meteor.
Stars: ✭ 24 (+84.62%)
Mutual labels:  reactive
reactiverse
The Reactiverse main entry point
Stars: ✭ 26 (+100%)
Mutual labels:  reactive
ReactiveAPI
Write clean, concise and declarative network code relying on URLSession, with the power of RxSwift. Inspired by Retrofit.
Stars: ✭ 79 (+507.69%)
Mutual labels:  reactive
DashIntro
A quick intro to Dash made for the PyData event in Zurich
Stars: ✭ 57 (+338.46%)
Mutual labels:  reactive
r2dbc-proxy
R2DBC Proxying Framework
Stars: ✭ 108 (+730.77%)
Mutual labels:  reactive
Wires
Light binding library for Xamarin
Stars: ✭ 34 (+161.54%)
Mutual labels:  binding
akka-cookbook
提供清晰、实用的Akka应用指导
Stars: ✭ 30 (+130.77%)
Mutual labels:  reactive
callbag-subscribe
A callbag sink (listener) that connects an Observer a-la RxJS. 👜
Stars: ✭ 17 (+30.77%)
Mutual labels:  reactive
onix
A reactive configuration manager designed to support Infrastructure as a Code provisioning, and bi-directional configuration management providing a single source of truth across multi-cloud environments.
Stars: ✭ 89 (+584.62%)
Mutual labels:  reactive

BindKit

A simple to use two-way data binding framework for iOS. Only one API to learn.

Supports Objective-C, Swift 5, Xcode 10.2, iOS 8 and above.

Ships as a cocoapod or static library ready for you to link into your app (or you can include the source directly into your project). The static library is built as a 'fat' library and includes the following architectures: i386, x86_64, armv7s, armv7, arm64 and bitcode.

Looking for an older version?

Tagged version 1.0.0 supports Objective-C, Swift 3 and 4, Xcode 8, 9 and 10, iOS 8 and above.

Currently supported views

The following views are supported directly by BindKit:

View class View properties
UIBarButtonItem enabled
UIButton enabled, hidden
UIDatePicker date, enabled, hidden
UIImageView image, hidden
UILabel text, attributedText, hidden
UIPageControl currentPage, numberOfPages, enabled, hidden
UISegmentedControl selectedSegmentIndex, enabled, hidden
UISlider value, enabled, hidden
UIStepper value, enabled, hidden
UISwitch on, enabled, hidden
UITextFieldText text, attributedText, enabled, hidden
UITextView text, attributedText, editable, hidden

Don't see the property or class you're interested in? Submit a pull request with your changes to add the property or class, or use the Vendor API to add custom functionality in your own app. See MySearchBar.swift in BindingExample for an example of custom functionality using the Vendor API.

Binding

Data binding is two-way - any changes to your models properties are automatically applied to your views properties and vice versa.

There is only one API to learn:

Objective-C

[model bindObjectSel: @selector(addressStr) toView: addressTextField viewKey: UITextFieldText];

Swift

model.bindObjectKey(#keyPath(model.addressStr), toView: addressTextField, viewKey: UITextFieldText)

Just a few simple rules

The following rules apply when using BindKit with Swift:

  1. Your model object must inherit from NSObject.
  2. Your models properties that participate in binding need to be marked @objc dynamic.

See under the hood for implementation details.

Example

Swift

class LogonModel: NSObject {
	
	@objc dynamic var username: String!
	@objc dynamic var password: String!
	@objc dynamic var logonEnabled: Boolean
	
	override func boundPropertiesDidUpdate() {
		logonEnabled = validate()
	}

	func validate() -> Boolean
		guard username!.trimmingCharacters(in: CharacterSet.whitespaces).count > 0 else { return false }
		guard password!.trimmingCharacters(in: CharacterSet.whitespaces).count > 0 else { return false }
		return true
	}
}

class LogonController: UITableViewController {

	@IBOutlet weak var usernameTextField: UITextField!
	@IBOutlet weak var passwordTextField: UITextField!
	@IBOutlet weak var logonButton: UIButton!

	var model = LogonModel()

	override func viewDidLoad() {
		model.bindKey(#keyPath(model.username), view: usernameTextField, viewKey: UITextFieldText)
		model.bindKey(#keyPath(model.password), view: passwordTextField, viewKey: UITextFieldText)
		model.bindKey(#keyPath(model.logonEnabled), view: logonButton, viewKey: UIButtonEnabled)
	}

}

Adding BindKit to your app (Manual integration)

  • Link libBindKit.a into your app
  • Configure Header Search Paths to allow Xcode to find BindKit.h and BindKitVendor.h
  • Add -ObjC and -all_load to Other Linker Flags

Adding BindKit to your app (Cocoapods integration)

  • If you have not already created a Podfile for your application, create one now: pod init
  • Add the following into your Podfile: pod 'BindKit'
  • Save the file and run: pod install

Building

Whilst the libBindKit.a static library is prebuilt and included in the repository, if you need to rebuild then execute the following command:

./buildlibrary.sh

The resulting static library and header files will be placed into the release directory.

The build script currently assumes Xcode 10.2/SDK12.2. If you are using a different Xcode build chain, tweak the IOSSDK_VER variable in the build script as appropriate.

Under the hood

Model

Model properties that participate in binding are monitored for changes using Key-Value-Observing (KVO). For this reason model objects must inherit from NSObject, and if using Swift, properties must be marked with @objc dynamic.

View

Views that participate in binding are dynamically subclassed at runtime. There is one dynamic subclass implemented for each supported view. Depending on the view, different methods for monitoring changes are required: target-action, delegation or notifications.

View not supported? Submit a pull request with your changes to add the property or class, or use the Vendor API to add custom functionality in your own app.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].