private void onState (final State tgtState, final Signal.Listener<? super Layer> action) { state.connect(new Signal.Listener<State>() { public void onEmit (State state) { if (state == tgtState) action.onEmit(Layer.this); } }); }
/** * Automatically connects {@code onPaint} to {@code paint} when {@code layer} is added to a scene * graph, and disconnects it when {@code layer} is removed. */ public static void bind (Layer layer, final Signal<Clock> paint, final Slot<Clock> onPaint) { layer.state.connectNotify(new Slot<Layer.State>() { public void onEmit (Layer.State state) { _pcon = Closeable.Util.close(_pcon); if (state == Layer.State.ADDED) _pcon = paint.connect(onPaint); } private Closeable _pcon = Closeable.Util.NOOP; }); }
@Override protected Connection connect () { conn = mapped.connect(new UnitSlot() { public void onEmit () { reconnect(); } }); return mapped.get().connect(new Listener<M>() { @Override public void onChange (M value, M ovalue) { notifyChange(value, ovalue); } }); } @Override protected void disconnect () {
public Closeable connect () { return textV.map(Functions.TO_STRING).connectNotify(text.slot()); } @Override public String toString () {
public Boolean apply (Iterable<? extends ValueView<Boolean>> values) { for (ValueView<Boolean> value : values) { if (value.get()) return true; } return false; } };
/** * Returns a value which is the logical NOT of the supplied value. */ public static ValueView<Boolean> not (ValueView<Boolean> value) { return value.map(Functions.NOT); }
public Boolean apply (Iterable<? extends ValueView<Boolean>> values) { for (ValueView<Boolean> value : values) { if (value.get()) return true; } return false; } };
/** * Returns a value which is the logical NOT of the supplied value. */ public static ValueView<Boolean> not (ValueView<Boolean> value) { return value.map(Functions.NOT); }
/** * Automatically connects {@code onUpdate} to {@code update}, and {@code onPaint} to {@code * paint} when {@code layer} is added to a scene graph, and disconnects them when {@code layer} * is removed. */ public static void bind (Layer layer, final Signal<Clock> update, final Slot<Clock> onUpdate, final Signal<Clock> paint, final Slot<Clock> onPaint) { layer.state.connectNotify(new Slot<Layer.State>() { public void onEmit (Layer.State state) { _pcon = Closeable.Util.close(_pcon); _ucon = Closeable.Util.close(_ucon); if (state == Layer.State.ADDED) { _ucon = update.connect(onUpdate); _pcon = paint.connect(onPaint); } } private Closeable _ucon = Closeable.Util.NOOP, _pcon = Closeable.Util.NOOP; }); }
@Override protected Connection connect () { conn = mapped.connect(new UnitSlot() { public void onEmit () { reconnect(); } }); return mapped.get().connect(new Listener<M>() { @Override public void onChange (M value, M ovalue) { notifyChange(value, ovalue); } }); } @Override protected void disconnect () {
public Boolean apply (Iterable<? extends ValueView<Boolean>> values) { for (ValueView<Boolean> value : values) { if (!value.get()) return false; } return true; } };
/** * Returns a reactive value which is false when this collection is empty, true otherwise. */ public ValueView<Boolean> isNonEmptyView () { return sizeView().map(Functions.greaterThan(0)); }
/** Convenience method to {@link ValueView#connectNotify} {@code slot} to {@link #isComplete}. * This is useful for binding the disabled state of UI elements to this future's completeness * (i.e. disabled while the future is incomplete, then reenabled when it is completed). * @return this future for chaining. */ public RFuture<T> bindComplete (SignalView.Listener<Boolean> slot) { isComplete().connectNotify(slot); return this; }
public Boolean apply (Iterable<? extends ValueView<Boolean>> values) { for (ValueView<Boolean> value : values) { if (!value.get()) return false; } return true; } };
/** * Returns a reactive value which is true when this collection is empty, false otherwise. */ public ValueView<Boolean> isEmptyView () { return sizeView().map(Functions.lessThanEqual(0)); }
public Closeable connect () { return iconV.connectNotify(icon.slot()); } @Override public String toString () {