lib/jrubyfx/core_ext/observable_value.rb
##
# call-seq:
#   add_change_listener { |observable, old_value, new_value| block }
#   add_change_listener { |new_value| block }
#
# Add a ruby block to call when the property changes changes


Add a ruby block to call when the property changes changes
Add a ruby block to call when the property changes changes
def add_change_listener(type=nil, &block)
    unless type
      type = :list if self.is_a? Java::javafx::collections::ObservableList
      type = :map if self.is_a? Java::javafx::collections::ObservableMap
    end
    if type == :list || type == :map
      super(&block)
    else
      old_verbose = $VERBOSE
      begin
        $VERBOSE = nil
        addListener(ChangeListener.impl {|name, x, y, z|
            if block.arity == 1
              block.call(z) 
            else
              block.call(x, y, z)
            end
          })
      ensure
        $VERBOSE = old_verbose
      end
    end
  end
def add_change_listener ( type = nil , & block ) unless type type = :list if self . is_a? Java :: javafx :: collections :: ObservableList type = :map if self . is_a? Java :: javafx :: collections :: ObservableMap end if type == :list || type == :map super ( & block ) else old_verbose = $VERBOSE begin $VERBOSE = nil addListener ( ChangeListener . impl { | name , x , y , z | if block . arity == 1 block . call ( z ) else block . call ( x , y , z ) end } ) ensure $VERBOSE = old_verbose end end end
call-seq:
add_change_listener { |observable, old_value, new_value| block }
add_change_listener { |new_value| block }
call - seq : add_change_listener { |observable old_value new_value| block } add_change_listener { |new_value| block }
# just call with new # always re-set to old value, even if block raises an exception
type
<not_specific>
block
<not_specific>