Package io.github.astrapi69.design.pattern.observer.api
package io.github.astrapi69.design.pattern.observer.api
Provides interfaces that define the core components of the observer design pattern
The observer pattern is a behavioral design pattern that allows an object, known as the subject, to maintain a list of its dependents, called observers, and notify them automatically of any state changes, usually by calling one of their methods This package contains the fundamental interfaces that are essential for implementing the observer pattern.
The key interfaces in this package include:
Observer
- Represents the observer that watches the subject for changesSubject
- Represents the subject being observedActionCommand
- Represents a command that can be executed, typically used by observers to respond to subject changes
These interfaces provide a flexible and extensible framework for implementing the observer pattern in various contexts By adhering to these interfaces, developers can create systems where objects can be notified of changes in other objects' states, promoting loose coupling and dynamic behavior.
-
InterfacesClassDescriptionThe interface
ActionCommand
represents a command that can be executed Implementations of this interface encapsulate a specific action that can be triggeredObserver<T>The InterfaceObserver
represents an observer in the Observer design pattern It defines a contract for objects that should be notified of changes in an observable subjectThe interfaceSubject
represents the "subject" in the Observer design pattern The subject is the object whose state changes are being observed by one or more observers When the state of the subject changes, the observers are notified of the change