[DOC] add generic documentation
This commit is contained in:
parent
70245bef36
commit
e43388d091
@ -70,6 +70,50 @@ class ConnectedElementDynamic<T> extends ConnectedElement<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple interface to manage signal connection and disconnection
|
||||
* <pre>{@code
|
||||
* class EmiterSimple {
|
||||
* public Signal<String> signalEvent = new Signal<>();
|
||||
* }
|
||||
*
|
||||
* class ReceiverSimple {
|
||||
* public void onEvent(String data) {
|
||||
* Log.error("function receive: " + data);
|
||||
* }
|
||||
* public connectLambda(EmiterSimple other) {
|
||||
* // Note : this lambda is reference a a global, then it will never removed in the connection list ==> refer the local class or @see connectAutoRemoveObject
|
||||
* other.signalEvent.connect((data) -> {
|
||||
* Log.error("lambda receive: " + data);
|
||||
* });
|
||||
* }
|
||||
* }
|
||||
* // use :
|
||||
* EmiterSimple aaa = new EmiterSimple();
|
||||
* ReceiverSimple bbb = new ReceiverSimple();
|
||||
* // Emit a signal:
|
||||
* aaa.signalEvent.emit("My message ...");
|
||||
* // simple direct connection:
|
||||
* aaa.signalEvent.connect(bbb::onEvent);
|
||||
* //removable connection (2 possibilities:)
|
||||
* // First solution (best way ==> does not need to lock a reference on the current object and the remote)
|
||||
* {
|
||||
* Connection connect = aaa.signalEvent.connectDynamic(bbb::onEvent());
|
||||
* // disconnect
|
||||
* connect.disconnect();
|
||||
* }
|
||||
* // Second solution
|
||||
* {
|
||||
* Consumer<?> connect = bbb::onEvent;
|
||||
* aaa.signalEvent.connect(connect);
|
||||
* // disconnect
|
||||
* aaa.signalEvent.disconnect(connect);
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* @param <T> Type of the signal
|
||||
*
|
||||
*/
|
||||
public class Signal<T> implements ConnectionRemoveInterface {
|
||||
List<ConnectedElement<T>> data = new ArrayList<>();
|
||||
|
||||
|
@ -70,6 +70,51 @@ class BiConnectedElementDynamic<T, U> extends BiConnectedElement<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple interface to manage signal connection and disconnection
|
||||
* <pre>{@code
|
||||
* class EmiterSimple {
|
||||
* public Signal2<String, Double> signalEvent = new Signal2<>();
|
||||
* }
|
||||
*
|
||||
* class ReceiverSimple {
|
||||
* public void onEvent(String data, Double data2) {
|
||||
* Log.error("function receive: " + data + " " + data2);
|
||||
* }
|
||||
* public connectLambda(EmiterSimple other) {
|
||||
* // Note : this lambda is reference a a global, then it will never removed in the connection list ==> refer the local class or @see connectAutoRemoveObject
|
||||
* other.signalEvent.connect((data, data2) -> {
|
||||
* Log.error("lambda receive: " + data + " " + data2);
|
||||
* });
|
||||
* }
|
||||
* }
|
||||
* // use :
|
||||
* EmiterSimple aaa = new EmiterSimple();
|
||||
* ReceiverSimple bbb = new ReceiverSimple();
|
||||
* // Emit a signal:
|
||||
* aaa.signalEvent.emit("My message ...", 16516.541654);
|
||||
* // simple direct connection:
|
||||
* aaa.signalEvent.connect(bbb::onEvent);
|
||||
* //removable connection (2 possibilities:)
|
||||
* // First solution (best way ==> does not need to lock a reference on the current object and the remote)
|
||||
* {
|
||||
* Connection connect = aaa.signalEvent.connectDynamic(bbb::onEvent());
|
||||
* // disconnect
|
||||
* connect.disconnect();
|
||||
* }
|
||||
* // Second solution
|
||||
* {
|
||||
* Consumer<?> connect = bbb::onEvent;
|
||||
* aaa.signalEvent.connect(connect);
|
||||
* // disconnect
|
||||
* aaa.signalEvent.disconnect(connect);
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* @param <T> First type of the signal
|
||||
* @param <U> Second type of the signal
|
||||
*
|
||||
*/
|
||||
public class Signal2<T, U> implements ConnectionRemoveInterface {
|
||||
List<BiConnectedElement<T, U>> data = new ArrayList<>();
|
||||
|
||||
|
@ -69,6 +69,48 @@ class ConnectedElementDynamicEmpty extends ConnectedElementEmpty {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple interface to manage signal connection and disconnection
|
||||
* <pre>{@code
|
||||
* class EmiterSimple {
|
||||
* public SignalEmpty signalEvent = new SignalEmpty();
|
||||
* }
|
||||
*
|
||||
* class ReceiverSimple {
|
||||
* public void onEvent() {
|
||||
* Log.error("function receive event ...");
|
||||
* }
|
||||
* public connectLambda(EmiterSimple other) {
|
||||
* // Note : this lambda is reference a a global, then it will never removed in the connection list ==> refer the local class or @see connectAutoRemoveObject
|
||||
* other.signalEvent.connect(() -> {
|
||||
* Log.error("lambda receive event");
|
||||
* });
|
||||
* }
|
||||
* }
|
||||
* // use :
|
||||
* EmiterSimple aaa = new EmiterSimple();
|
||||
* ReceiverSimple bbb = new ReceiverSimple();
|
||||
* // Emit a signal:
|
||||
* aaa.signalEvent.emit();
|
||||
* // simple direct connection:
|
||||
* aaa.signalEvent.connect(bbb::onEvent);
|
||||
* //removable connection (2 possibilities:)
|
||||
* // First solution (best way ==> does not need to lock a reference on the current object and the remote)
|
||||
* {
|
||||
* Connection connect = aaa.signalEvent.connectDynamic(bbb::onEvent());
|
||||
* // disconnect
|
||||
* connect.disconnect();
|
||||
* }
|
||||
* // Second solution
|
||||
* {
|
||||
* Consumer<?> connect = bbb::onEvent;
|
||||
* aaa.signalEvent.connect(connect);
|
||||
* // disconnect
|
||||
* aaa.signalEvent.disconnect(connect);
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
*/
|
||||
public class SignalEmpty implements ConnectionRemoveInterface {
|
||||
List<ConnectedElementEmpty> data = new ArrayList<>();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user