valuelane.set(swim.Value.fromAny("john"))
instead. This will convert your string to a Swim Value.
let oldvalue = valueLane.get();
valueLane.set("john");
console.log(oldvalue);
oldvalue = valueLane.get();
console.log(oldvalue);
This should print Absent
and then "john".
valueLane.get()
returns the current value of that valueLane()
@ajay-gov got it. what im trying to achieve is, to get the old and new value on the client side.
on the server side,
@SwimLane("info")
ValueLane<String> info = this.<String>valueLane()
.didSet((newValue, oldValue) -> {
logMessage("`info` set to " + newValue + " from " + oldValue);
});
this prints the old and new value every time i set a new value. like this, [/welcome/user]
infoset to hello from world
but on client side,
.didSet((newValue, oldValue) => {
console.log("link watched info change to " + newValue + " from " + oldValue);
})
this always comes as absent.
Maybe I'm understanding the purpose of value lane incorrectly?
@vishnuprasad73_twitter
const client = new swim.WarpClient();
let valueLane = client.downlinkValue()
.hostUri("warp://localhost:9001").nodeUri("/welcome/user").laneUri("info")
.didSet((newValue, oldValue) => {
console.log("link watched info change to " + newValue + " from " + oldValue);
})
.open();
is all you need. Whenever the "info" lane for the node "/welcome/user" gets updated on the server then the didSet
callback in the valueLane
reference in the client should get invoked with the oldValue
and the newValue
. Are you not seeing this?
@ajay-gov i tried that. but when i set a new value, the callback im getting on the client side is,link watched info change to john from Value.absent()
i have the same callback on server side, which works correctly.
@SwimLane("info")
ValueLane<String> info = this.<String>valueLane()
.didSet((newValue, oldValue) -> {
logMessage("`info` set to " + newValue + " from " + oldValue);
});
which logs out put as below,
[/welcome/user] `info` set to doe from john
valuelane.set(swim.Value.fromAny("john"))
still it shows as absent on client side though
client.close
the connection to the server is closed and all downlinks will stop getting the data from the server.