File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
src/main/java/org/codefx/libfx/listener/handle Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 5
5
import java .util .function .BiConsumer ;
6
6
7
7
/**
8
- * A builder for a {@link ListenerHandle}.
8
+ * A builder for a {@link ListenerHandle}. Note that it is abstract enough to be used for all kinds of
9
+ * observable/listener relation and not just for those occurring in JavaFX.
9
10
* <p>
10
11
* The created handle manages whether the listener is currently attached. The functions specified to
11
12
* {@link #onAttach(BiConsumer)} and {@link #onDetach(BiConsumer)} are only called when necessary. This is the case
16
17
* This implies that they can be stateless functions which simply add and remove the listener. The functions are called
17
18
* with the observable and listener specified during construction.
18
19
* <p>
19
- * The {@link ListenerHandle} returned by this builder is not yet attached.
20
+ * The {@link ListenerHandle} returned by this builder is not yet attached, i.e. it does not initially call the
21
+ * functions give to {@code onAttach} or {@code onDetach}.
20
22
* <p>
21
23
* <h2>Example</h2> A typical use looks like this:
22
24
*
Original file line number Diff line number Diff line change 1
1
/**
2
- * TODO
2
+ * This package provides classes which make it easier to add and remove listeners from observable instances.
3
+ * <p>
4
+ * Using the default JavaFX 8 features, it is necessary to store both the observed instance and the listener if the
5
+ * latter has to be added or removed repeatedly. A {@link org.codefx.libfx.listener.handle.ListenerHandle
6
+ * ListenerHandle} encapsulates those references and the state whether a listener is currently added or not. It provides
7
+ * an {@link org.codefx.libfx.listener.handle.ListenerHandle#attach() attach()} and a
8
+ * {@link org.codefx.libfx.listener.handle.ListenerHandle#detach() detach} method which add or remove the listener.
9
+ * Redundant calls (i.e. attaching when the listener is already added) are no-ops.
10
+ * <p>
11
+ * All features of <b>LibFX</b> which deal with listeners are aware of {@code ListenerHandle}s and respective methods
12
+ * will return them. For observable classes included in the JDK, the factory
13
+ * {@link org.codefx.libfx.listener.handle.ListenerHandles ListenerHandles} provides methods to easily create a handle.
14
+ *
15
+ * @see org.codefx.libfx.listener.handle.ListenerHandle ListenerHandle
16
+ * @see org.codefx.libfx.listener.handle.ListenerHandles ListenerHandles
3
17
*/
4
18
package org .codefx .libfx .listener .handle ;
You can’t perform that action at this time.
0 commit comments