Skip to content

Instantly share code, notes, and snippets.

@komax
Created July 30, 2013 15:08
Show Gist options
  • Save komax/6113803 to your computer and use it in GitHub Desktop.
Save komax/6113803 to your computer and use it in GitHub Desktop.
# See http://docs.oracle.com/javafx/2/collections/jfxpub-collections.htm
require 'jrubyfx'
# Example for an ObservableList
list = []
observable_list = FXCollections.observable_list(list)
observable_list.add_change_listener do
puts "Detected a change!"
end
observable_list << "item one"
list << "item two"
puts "Size: #{observable_list.size}"
# Example for an ObservableMap
my_map = {}
ob_map = FXCollections.observable_map(my_map)
#FIXME this listener does not listen, why?
ob_map.add_change_listener do
puts "Detected a change!"
end
ob_map[:key_1] = "value 1"
my_map[:key_2] = "value 2"
puts "Size: #{ob_map.size}"
# Output should be:
# Detected a change!
# Size: 2
# Detected a change! <- does not occur with the observable map above
# Size: 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment