Sha256: a325cc57740e9e20fe9148b3f7f4e3910540cbb9cc36af5e89074300d1c599fe

Contents?: true

Size: 494 Bytes

Versions: 1

Compression:

Stored size: 494 Bytes

Contents

module MotionBindable::Strategies

  class UITextField < ::MotionBindable::Strategy

    def on_bind
      update_attribute
      NSNotificationCenter.defaultCenter.addObserver(
        self,
        selector: :on_change,
        name: UITextFieldTextDidChangeNotification,
        object: bound
      )
    end

    def on_change
      update_attribute
    end

    alias_method :refresh, :on_change

    private

    def update_attribute
      self.attribute = bound.text
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
motion_bindable-0.0.6 lib/strategies/ui_text_field.rb