Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop 0.0.4 swift3 #5

Merged
72 commits merged into from Jun 21, 2018
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
81fba74
Rename Binding -> BindableProperty
darrenclark Feb 12, 2016
7233168
Replace NSObject+AssociatedObjects
darrenclark Feb 12, 2016
91d3993
Convert Subscribable to a base class
darrenclark Feb 12, 2016
e201143
Add concept of 'BindingHandlers'
darrenclark Feb 12, 2016
41b8bd1
BindingHandler creation helper functions
darrenclark Feb 16, 2016
cbe1979
Bidirectional bindings - BindingHandler support
darrenclark Feb 16, 2016
97ee9d9
Bidirectional properties work with Transform now
darrenclark Feb 16, 2016
9fb045b
Bidirectional bindings - prevent infinite loop
darrenclark Feb 16, 2016
b5a0ccf
Merge branch 'bindings-refactor' into develop-0.0.3
darrenclark Feb 16, 2016
8a0c4d7
Deprecate custom operators (+=, -->, <--)
darrenclark Feb 16, 2016
13030a8
Deprecated some overloads of `.bind(...)`
darrenclark Feb 16, 2016
ab1d62d
BindableProperty - Better support for optionals
darrenclark Feb 16, 2016
928b7f0
BidirectionalBindableProperty - optionals support
darrenclark Feb 16, 2016
6c71395
Check UIKit bindings for nullability
darrenclark Feb 16, 2016
e0dcd7c
Merge branch 'binding-optionals' into develop-0.0.3
darrenclark Feb 16, 2016
3ede430
UIImageView.image binding & image download support
darrenclark Feb 17, 2016
e3dc989
Merge branch 'UIImageView-bindings' into develop-0.0.3
darrenclark Feb 17, 2016
d2c53c8
LoadImageBindingHandler - log errors
darrenclark Feb 18, 2016
be0c149
Make `BindingHandler.init` public
darrenclark Mar 3, 2016
98609ac
Add WriteableComputed
darrenclark Mar 7, 2016
2210c8a
(Writable)Computed - Fix dependency tracking bug
darrenclark Mar 7, 2016
634a48b
DataSource - Fix selection bug
darrenclark Mar 7, 2016
5f77e80
Computed: coalesce updates
darrenclark Mar 8, 2016
4ead753
Computed: Fix propagation delay
darrenclark Mar 8, 2016
81961f5
Computed: Only calculate value once on init()
darrenclark Mar 8, 2016
9dae0f0
Computed - add test for coalescing
darrenclark Mar 8, 2016
d9797ca
WritableComputed - coalesce updates
darrenclark Mar 8, 2016
b93ce9d
Merge branch 'computed-performance-improvements' into develop-0.0.3
darrenclark Mar 8, 2016
937faf8
WritableComputed: fix dirty .value bug
darrenclark Mar 8, 2016
73a2856
Computed - fix infinite recursion bug
darrenclark Mar 8, 2016
53c787c
DataSource - fix selection bug
darrenclark Mar 8, 2016
574cc37
Bindings: Change UIColor! -> UIColor?
darrenclark Mar 18, 2016
3bc3f7f
Add UIBarItem title/enabled bindings (fixes GH #3)
darrenclark Mar 18, 2016
b8bf5f8
Improve performance of dependency tracking
darrenclark Mar 24, 2016
8b04d4a
LoadImageBindingHandler - fix race conditions
darrenclark Mar 24, 2016
e97b365
LoadImageBindingHandler - expose image cache
darrenclark Mar 28, 2016
84f0b61
(Bidirectional)BindableProperty - make init public
darrenclark Mar 31, 2016
5f1accb
UILabel - add binding for attributedText
darrenclark Apr 4, 2016
0ba9eec
UIActivityIndicatorView bindings (fixes GH #2)
darrenclark Apr 6, 2016
565c4e0
UILabel.textAlignment bindings
darrenclark Apr 6, 2016
3296a8b
Make pushChangeToObservable() public
darrenclark Apr 19, 2016
5f4ff68
Add BindingHandlers.computed(...)
darrenclark May 5, 2016
65018d1
Added a binding for UIAlertAction’s enabled property.
lessthanyouthink May 25, 2016
82ad842
Make DisposableBag.init() public
darrenclark Jun 7, 2016
533d556
Improve LoadImageBindingHandler flexibility
darrenclark Jun 21, 2016
463d7c4
Add missing dispose() calls in BindingHandlers
darrenclark Jun 21, 2016
6fe2f49
DependencyTracker - fix threading issues
darrenclark Jun 30, 2016
d79fb50
SubscriptionCollection - add appropriate locking
darrenclark Jul 4, 2016
14d8e74
Update Quick & Nimble
darrenclark Jul 6, 2016
fa04602
Fix double notify bug in (Writable)Computed
darrenclark Jul 6, 2016
3cd078c
DependenciesCollectionStack - thread dict key
darrenclark Aug 16, 2016
8e42a6b
Fix BindingHandlers.computed
darrenclark Aug 31, 2016
3ef424b
Get project compiling under Swift 3
darrenclark Oct 7, 2016
e395692
Cleanup warnings re: Swift 3 migration
darrenclark Oct 7, 2016
f055815
Added a property to DataSource to enable/disable update animations.
lessthanyouthink Oct 28, 2016
f35be5a
Add binding extension to UIRefreshControl’s refreshing property
robinsenior Dec 1, 2016
54ed9d1
update readme to have an assignment statement
robinsenior Dec 21, 2016
0bfa7bb
Implement ThrottleBindingHandler class
Dec 21, 2016
fe20547
Update Samples to demonstrate ThrottleBindingHandler
Dec 22, 2016
0632781
Fix OptionalBindingHandler
Dec 23, 2016
934d8b0
Re-factor the code to allow more flexibility when specifying a thrott…
Jan 3, 2017
3360327
Remove obsolete code
Jan 3, 2017
26621ca
Fix a typo in the documentation
Jan 3, 2017
640790e
add binding handlers info from the SUP docs
robinsenior Jan 4, 2017
5af0997
Merge pull request #6 from maxkorytko/feature/throttle-binding-handler
maxkorytko Jan 4, 2017
cb18f95
add bindings for UIButton attributedTitle
robinsenior Jan 11, 2017
0ecabdb
Added a bindable property for UIView’s isUserInteractionEnabled.
lessthanyouthink Feb 14, 2017
880bcfb
Updated project settings as per Xcode 8.3’s recommendations. Fixed a …
lessthanyouthink Mar 29, 2017
2d3a9e6
Fix potential UICollectionView crash
darrenclark Jul 20, 2017
3a104e0
Merge pull request #8 from scoremedia/fix-crash-when-inserting-items-…
darrenclark Jul 20, 2017
c33ef6c
Improve fix for UICollectionView crash
darrenclark Jul 26, 2017
f127117
Merge pull request #9 from scoremedia/improved-fix-for-crash-when-ins…
darrenclark Jul 26, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
153 changes: 129 additions & 24 deletions Fisticuffs.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

65 changes: 13 additions & 52 deletions README.md
Expand Up @@ -41,11 +41,11 @@ class LoginViewController: UIViewController {
super.viewDidLoad()

// bind the text in our username & password fields to their
usernameField.b_text <-> username
passwordField.b_text <-> password
usernameField.b_text.bind(username)
passwordField.b_text.bind(password)

// only enable the login button if they've entered an username and password
loginButton.b_enabled <-- inputIsValid
loginButton.b_enabled.bind(inputIsValid)

// do the login when the user taps the login button
loginButton.b_onTap.subscribe { [weak self] in
Expand Down Expand Up @@ -107,50 +107,14 @@ event.fire("Hello, world")

### Subscribable

As a side note, `Observable`, `Computed`, and `Event` all implement the same `Subscribable` protocol to provide a common interface to subscribing to changes/events.
As a side note, `Observable`, `Computed`, and `Event` all inherit from `Subscribable` to provide a common interface to subscribing to changes/events.


## UI Bindings

### Binding Setup
### Property bindings

UI binding are setup using the following operators:

- `<--` / `-->`

One-way binding. Data flows in the direction of the arrow. For example:
```swift
let messageLabel: UILabel = ...
let message = Observable("")
messageLabel.b_text <-- message

message.value = "Uh oh, an error has occurred"
// updates messageField's text automatically
```

- `<->`

Two-way binding. Data flows both directions. For example, a `UITextField`'s `text` property can be changed by the user or in code by the programmer.
```swift
let nameField: UITextField = ...
let name = Observable("")
nameField.b_text <-> name

// `name` will stay in sync with `nameField`'s `text` property, whether we change the value of `name` or the user enters text into the text field
```

Or, if you prefer to avoid custom operators, you can use the provided `bind` method:

```swift
let messageLabel: UILabel = ...
let message = Observable("")
messageLabel.b_text.bind(message)
```


### Properties

Generally, bindings for UIKit classes are the original property name prefixed with `b_`. For example:
Many of the `UIKit` classes have been extended to allow binding their properties to `Subscribables`. These properties are generally to


UIKit | Fisticuffs
Expand All @@ -161,6 +125,13 @@ UIKit | Fisticuffs
`UISwitch`.`on` | `UISwitch`.`b_on`
*etc...*

To bind a `Subscribable` (ie: `Observable`, `Computed`, etc...) to these, the `bind()` method can be used.

```swift
let messageLabel: UILabel = ...
let message = Observable("")
messageLabel.b_text.bind(message)
```

### Events

Expand All @@ -174,16 +145,6 @@ button.b_onTap.subscribe {
}
```

Additionally, as syntactic sugar, a `+=` operator is provided for subscribing to events:

```swift
let button: UIButton = ...

button.b_onTap += {
print("Pressed button!")
}
```

### UITableViews / UICollectionViews

Fisticuffs provides support for easily binding data to UITableViews / UICollectionViews. See example below:
Expand Down
12 changes: 6 additions & 6 deletions Samples/AppDelegate.swift
Expand Up @@ -28,30 +28,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(application: UIApplication) {
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(application: UIApplication) {
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

Expand Down