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 55import java .util .function .BiConsumer ;
66
77/**
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.
910 * <p>
1011 * The created handle manages whether the listener is currently attached. The functions specified to
1112 * {@link #onAttach(BiConsumer)} and {@link #onDetach(BiConsumer)} are only called when necessary. This is the case
1617 * This implies that they can be stateless functions which simply add and remove the listener. The functions are called
1718 * with the observable and listener specified during construction.
1819 * <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}.
2022 * <p>
2123 * <h2>Example</h2> A typical use looks like this:
2224 *
Original file line number Diff line number Diff line change 11/**
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
317 */
418package org .codefx .libfx .listener .handle ;
You can’t perform that action at this time.
0 commit comments