sialcasa / mvvmFX

an Application Framework for implementing the MVVM Pattern with JavaFX
Apache License 2.0
486 stars 104 forks source link

Add possibility to replace the implementation of NotificationCenter #116

Open manuel-mauky opened 10 years ago

tfleis commented 7 years ago

Currently we barely use the notification mechanism of mvvmFX. The concept with the message names and objects as payload is very error prone and not much object oriented. I have an idea to make it more useable. Google Guava has an implementation of an EventBus. This or a similar implementation can be used as the base for a new notification mechanism. Each ViewModel and each Scope has an instance of an EventBus. All Views in case of the ViewModel are automatically registered to the EventBus from the related ViewModel. In case of a Scope all classes which can inject that Scope are also automatically registered to the EventBus of the related Scope. To receive an event all I have to do is to implement and annotate a method. There is not need to manually register to the event source. The publish method expects an Object as parameter (event with payload). The receiver expects the event class with payload as parameter in the listener method.