Sha256: 5dee649686bd575af2937ef205c5e37989f78de2f14aabf5ce97d194e495d1f0

Contents?: true

Size: 506 Bytes

Versions: 1

Compression:

Stored size: 506 Bytes

Contents

module MotionBindable::Strategies
  class UILabel < ::MotionBindable::Strategy
    include MotionBindable::StrategyHelpers

    def start_observing_object
      observe_object { |_, new| on_object_change(new) }
    end

    def on_object_change(new = nil)
      @bound.text = (new || attribute)
      @bound.setNeedsDisplay
    end

    def observeValueForKeyPath(_, ofObject: _, change: _, context: _)
      on_object_change
    end

    def unbind
      stop_observe_object
      super
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
motion_bindable-0.3.0 lib/strategies/ui_label.rb