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

[WIP] Bindings! #84

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open

[WIP] Bindings! #84

wants to merge 35 commits into from

Conversation

liscio
Copy link

@liscio liscio commented Feb 2, 2016

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 Signals 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. 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.

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...
@liscio liscio changed the title Bindings! [WIP] Bindings! Feb 2, 2016
@neilpa
Copy link
Member

neilpa commented Feb 3, 2016

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.

@liscio
Copy link
Author

liscio commented Feb 3, 2016

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants