• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Handle various observers in different ways

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For example I have an Observable and 2 various obeserver. I need to pass two different type of object to them. How can I use Observer-Observable design pattern in this context? Or Do I need to go for some other ways? If so what's it?
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my opinion it's best not to use Observable and Observer at all, because Observable should have been an interface, and they are not strongly typed.

Instead, write a listener interface for each event that you want to listen for. The class that you want to observe should provide methods that can add and remove listeners for a specific event.

Maybe you can explain a bit more what the different types of objects are that you want to pass around?
 
reply
    Bookmark Topic Watch Topic
  • New Topic