Open Source Swift Library Providing Easy To Use Swift Binding

Some time ago I mentioned the objective-c ReactiveCocoa library which at it’s core uses signals to allow you to bind multiple elements together to automatically watch for value changes.

Here’s an open source library called Bond from Srdan Rasic that adds a new operator to Swift that makes binding dead simple.

This example from the readme shows to bind the state of a text field to a label with Bond you could simply use:

textField ~> label

And this more complex example shows how one could dynamically update a table view with a repository data source object:

repositories.map { [unowned self] (repository: Repository) -> RepositoryTableViewCell in
      let cell = self.tableView.dequeueReusableCellWithIdentifier("cell") as RepositoryTableViewCell
      repository.name ~> cell.nameLabel
      repository.photo ~> cell.avatarImageView
      return cell
    } ~> self.tableView

Included within Bond are many helpers specifically for working with UIKit, arrays, KVO, and more with a number of code snippets in the readme, and a nice example showing how to dynamically update a table view with updated data.

You can find Bond on Github here.

A nice and simple bindings framework for Swift.

Original article: Open Source Swift Library Providing Easy To Use Swift Binding

©2015 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *