public interface ViewModel
Interface for a View Model.
You can use a notification mechanism by using the publish(String, Object...)
method. In the View you can
subscribe to this notifications by using viewModel.
subscribe(String messageName, NotificationObserver observer)
.
Some additional hints to this layer:
Never create a dependency to the view in this layer - if you have to create a new view after a business step, notify
the view with the NotificationCenter
or a callback that the view can create the new view. When you write a
new View
you should create the associated ViewModel
with tests before.
Modifier and Type | Method and Description |
---|---|
default void |
publish(String messageName,
Object... payload)
Publishes a notification to the subscribers of the notificationId.
|
default void |
subscribe(String messageName,
NotificationObserver observer)
Subscribe to a notification with a given
NotificationObserver . |
default void |
unsubscribe(NotificationObserver observer)
Removes the observer for all messages.
|
default void |
unsubscribe(String messageName,
NotificationObserver observer)
Remove the observer for a specific notification by a given messageName.
|
default void publish(String messageName, Object... payload)
messageName
- of the notificationpayload
- to be senddefault void subscribe(String messageName, NotificationObserver observer)
NotificationObserver
.
The observer will be invoked on the UI thread.messageName
- of the Notificationobserver
- which should execute when the notification occursdefault void unsubscribe(String messageName, NotificationObserver observer)
messageName
- of the notification for that the observer should be removedobserver
- to removedefault void unsubscribe(NotificationObserver observer)
observer
- to be removedCopyright © 2015 Saxonia Systems AG. All rights reserved.