You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the MVVM pattern the ViewModel may not have a dependency to the View but it can send notifications to the View.
An example use case is the triggering of an animation in the View. The Logic of when the animation should start is defined in the ViewModel and the definition of the animation is part of the View.
At the moment there are at least three ways of modeling this use case:
Use a BooleanProperty in the ViewModel that switches to true when the animation should start. The downside of this approach is that this kind of modeling is quite inadequate: A BooleanProperty represents state but we need a signal.
the View adds a callback on the ViewModel that the ViewModel can call. This approach needs a lot of code.
Use the NotificationCenter. The downside of this approach is that the NotificationCenter is global and therefore better suited for communication between different components of the application. For our use case we would like to have a better encapsulated approach.
In this issue we should think about a really easy solution. I'm thinking of something like this:
The ViewModel interface defines a method notify(String key) with a default implementation. The FxmlView interface defines a method subscribe(String key, Callback callback). The framework takes care for the handling of the notifications.
The text was updated successfully, but these errors were encountered:
In the MVVM pattern the ViewModel may not have a dependency to the View but it can send notifications to the View.
An example use case is the triggering of an animation in the View. The Logic of when the animation should start is defined in the ViewModel and the definition of the animation is part of the View.
At the moment there are at least three ways of modeling this use case:
true
when the animation should start. The downside of this approach is that this kind of modeling is quite inadequate: A BooleanProperty represents state but we need a signal.In this issue we should think about a really easy solution. I'm thinking of something like this:
The
ViewModel
interface defines a methodnotify(String key)
with a default implementation. TheFxmlView
interface defines a methodsubscribe(String key, Callback callback)
. The framework takes care for the handling of the notifications.The text was updated successfully, but these errors were encountered: