File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed
src/main/java/org/codefx/libfx/listener Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change 1
1
package org .codefx .libfx .listener ;
2
2
3
- // TODO what should the contract be for created handles? Always attached?
4
- // Answer: Up to the returning method to specify!
5
-
3
+ /**
4
+ * A listener handle can be used to {@link #attach() attach} and {@link #detach() detach} a listener to/from some
5
+ * observable instance. Using the handler the calling code must not manage references to both the observed instance and
6
+ * the listener, which can improve readability.
7
+ * <p>
8
+ * A handle is created and returned by methods which connect a listener with an observable instance. This usually means
9
+ * that the listener is actually added to the observable but it is also possible to simply return a handler and wait for
10
+ * the call to {@code attach()} before adding the listener. It is up to such methods to specify this behavior.
11
+ * <p>
12
+ * Unless otherwise noted it is not safe to share a handle between different threads. The behavior is undefined if
13
+ * parallel calls are made to {@code attach()} and/or {@code detach()}.
14
+ */
6
15
public interface ListenerHandle {
7
16
17
+ /**
18
+ * Adds the listener to the observable. Calling this method when the listener is already added is a no-op and will
19
+ * not result in the listener being called more than once.
20
+ */
8
21
void attach ();
9
22
23
+ /**
24
+ * Removes the listener from the observable. Calling this method when the listener is not added is a no-op.
25
+ */
10
26
void detach ();
11
27
12
28
}
Original file line number Diff line number Diff line change
1
+ /**
2
+ * TODO
3
+ */
4
+ package org .codefx .libfx .listener ;
You can’t perform that action at this time.
0 commit comments