• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

What is Observable?

 
Ranch Hand
Posts: 340
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No offense intended.  I think Java has several fancy descriptions for everyday concepts. I cannot even say that the Javadoc is making the concepts easier to understand.
So, I see things like ObservableMap<Object,​Object> and I am wondering what is Observable in ObservableMap.
Grateful if anyone can break it down for me to comprehend.
 
Saloon Keeper
Posts: 12493
269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a Map that's also Observable.

A map that allows observers to track changes when they occur.


An Observable is an entity that wraps content and allows to observe the content for invalidations.



What part are you having difficulties with?
 
Saloon Keeper
Posts: 6711
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is, I think, beyond dispute is that Observer and Observable are leftovers from Java's earliest days, and have long been replaced by other means like event listeners and (more recently) event buses.
 
Biniman Idugboe
Ranch Hand
Posts: 340
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

An Observable is an entity that wraps content and allows to observe the content for invalidations.


What does it allow?
 
Marshal
Posts: 26130
77
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was going to look it up in the API documentation, but it doesn't seem to be there. So, where is this ObservableMap class coming from?
 
Stephan van Hulst
Saloon Keeper
Posts: 12493
269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Moores wrote:What is, I think, beyond dispute is that Observer and Observable are leftovers from Java's earliest days, and have long been replaced by other means like event listeners and (more recently) event buses.


The Observable we're talking about is from JavaFX.

Biniman Idugboe wrote:What does it allow?


You can add a listener to an Observable and it will be notified when the Observable's previous known state is no longer valid. For an ObservableMap this means you will get notified when an entry has been added or removed.
 
Paul Clapham
Marshal
Posts: 26130
77
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And here's the API documentation which says that: https://docs.oracle.com/javase/8/javafx/api/javafx/collections/ObservableMap.html
 
Tim Moores
Saloon Keeper
Posts: 6711
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The Observable we're talking about is from JavaFX.


I see. It would have been better to use a different name rather than one that was already in use in the JDK for a similar, although distinct purpose (even if that one is obsolete for all practical purposes), IMO.
 
I like you because you always keep good, crunchy cereal in your pantry. This tiny ad agrees:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic