rubymotion-community / BubbleWrap

Cocoa wrappers and helpers for RubyMotion (Ruby for iOS and OS X) - Making Cocoa APIs more Ruby like, one API at a time. Fork away and send your pull requests
Other
1.18k stars 208 forks source link

Feature: `observe!` method for creating "initial" observer [+Bonus] #460

Closed y8 closed 9 years ago

y8 commented 9 years ago

This PR is adding observe! method that is in fact just creating observer with NSKeyValueObservingOptionInitial option. This method will help a lot with avoiding copying code form a block, when initial value must be set to receiver.

Also I've done a minor refactoring: observers blocks registration logic extracted to separate class BW::KWO::Registry.

y8 commented 9 years ago

It's community contribution day, so #390 is also implemented (with optional key_path argument) as a part of this PR.

markrickert commented 9 years ago

Nice! I love how detailed this change is! Merging.