Closed SirCipher closed 3 years ago
Code Sample for DemandValueLane
/**
* raw data
*/
@SwimLane("raw")
ValueLane<Value> raw = this.<Value>valueLane().didSet((n, o) -> {
this.data.cue();
});
/**
* data
*/
@SwimLane("data")
DemandLane<Value> data = this.<Value>demandLane().onCue(uplink -> {
return transformRaw();
});
// Transform raw data to the desired format
private Value transformRaw() {
final Value v = this.raw.get();
if (v.isDefined()) {
return transform(v);
} else {
return v;
}
}
Code sample for DemandMapLane
@SwimLane("raw")
protected MapLane<Value, Value> raw = this.<Value, Value>mapLane().didUpdate((key, newValue, oldValue) -> {
this.data.cue(key);
});
@SwimLane("data")
protected DemandMapLane<Value, Value> data = this.<Value, Value>demandMapLane().onCue((key, uplink) -> {
final Value raw = this.raw.get(key);
return transform(raw);
}).onSync(uplink -> {
return this.raw.keyIterator();
});
DemandValueLane
DemandMapLane
(could be in the same agent with theDemandValueLane
SwimClient
can sync to both the DemandLanes