-
Notifications
You must be signed in to change notification settings - Fork 31
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
[WIP] Bindings! #84
base: master
Are you sure you want to change the base?
[WIP] Bindings! #84
Conversation
In doing some of my own work, I found that I was duplicating a lot of what was already done in Rex, so I ported over much of what I've done on my own in order to better consolidate things. There isn't a complete 1:1 test matching at the moment with the new AppKit methods, and I "broke" the API for NSTextField that was already in place to better match with conventions used elsewhere in RAC, and to distinguish between continuous and "normal" control events.
Originally developed alongside a forthcoming update to FuzzMeasure (http://fuzzmeasure.com), this is my take on one way that Cocoa Bindings-like behavior may be approximated using RAC. In addition to the `Signal`s that contain controls' changing values, the `ConsumerBinding` provides the "other half" of the equation—updating their state to reflect incoming values. Like Cocoa Bindings, values are wrapped by placeholders that represent selection states such as `MultipleValues` and `NoSelection`. A new `PropertyBinding` is a similar concept that exists for model objects to expose, where a `validator` function is provided to allow the "massaging" of incoming values. This approximates the role of Key-Value Validation as it existed within Cocoa Bindings. This changeset does not include any examples, sadly. Hopefully I can put something together in the near future to share.
Trying to use Action-based triggers for values, in general, as NSControls have always worked on a target/action-based system.
The joy of importing code from an app into a framework is all the internal -> public promotion...
I did a quick pass on this but having never used Cocoa Bindings (or any meaningful Mac development for that matter) it'll take me a bit longer to digest this and offer feedback. |
@neilpa It's a lot to digest. I sort of "rushed" to dump this code (after carefully building it, and using it successfully) into the repo because I wanted to make it available for my other projects sooner. I'm hoping to come up with a small enough example to demonstrate this soon. |
# Conflicts: # .travis.yml # Cartfile # Cartfile.resolved # Rex.xcodeproj/project.pbxproj
Also made changes to port existing bindings code to Swift 3, to ensure it all still compiles.
Originally developed alongside a forthcoming update to FuzzMeasure (http://fuzzmeasure.com), this is my take on one way that Cocoa Bindings-like behavior may be approximated using RAC.
In addition to the
Signal
s that contain controls' changing values, theConsumerBinding
provides the "other half" of the equation—updating their state to reflect incoming values. Like Cocoa Bindings, values are wrapped by placeholders that represent selection states such asMultipleValues
andNoSelection
.A new
PropertyBinding
is a similar concept that exists for model objects to expose, where avalidator
function is provided to allow the "massaging" of incoming values. This approximates the role of Key-Value Validation as it existed within Cocoa Bindings.This changeset does not include any examples, sadly. Hopefully I can put something together in the near future to share. Also, I need to adjust whitespace as this code was built alongside a project that uses 4 spaces in place of tabs. 😛
In addition to the above, this PR includes some additional extensions for AppKit controls.