Package edu.wpi.grip.core.observables
Class SimpleObservable<T>
- java.lang.Object
-
- edu.wpi.grip.core.observables.SimpleObservable<T>
-
- Type Parameters:
T
- the type of the values to observe
- All Implemented Interfaces:
Observable<T>
- Direct Known Subclasses:
SynchronizedObservable
public class SimpleObservable<T> extends java.lang.Object implements Observable<T>
Default thread-unsafe implementation ofObservable
. For a thread-safe solution, seeSynchronizedObservable
.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addObserver(Observer<? super T> observer)
Add an observer to this observable.T
get()
Gets the current value of this observable.void
removeObserver(Observer<? super T> observer)
Removes an observer from this observable.void
set(T value)
Sets the value of this observable.
-
-
-
Method Detail
-
addObserver
public void addObserver(Observer<? super T> observer)
Description copied from interface:Observable
Add an observer to this observable. It will be notified of any future changes to the value of this observable. Listeners will be fired in the order in which they were added, and on the thread that updates the observed value. Because of this, listeners should take as little time as possible to run (unless submitting a long-running task to a worker thread).- Specified by:
addObserver
in interfaceObservable<T>
-
removeObserver
public void removeObserver(Observer<? super T> observer)
Description copied from interface:Observable
Removes an observer from this observable. The observer will not be updated with future changes to the value of this observable.- Specified by:
removeObserver
in interfaceObservable<T>
-
get
public T get()
Description copied from interface:Observable
Gets the current value of this observable.- Specified by:
get
in interfaceObservable<T>
-
set
public void set(T value)
Description copied from interface:Observable
Sets the value of this observable. If it's notequal
to the current value, all observers will be notified of the change.- Specified by:
set
in interfaceObservable<T>
-
-