[/user/john] Surname of John is "Hello World"
swim.codec.DecoderException: incomplete
compile group: 'org.swimos', name: 'swim-server', version: '3.10.0'
compile group: 'org.swimos', name: 'swim-api', version: '3.10.0'
compile group: 'org.swimos', name: 'swim-client', version: '3.10.0'
var swim = require("@swim/client");
var structure = require("@swim/structure");
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();
let oldvalue = valueLane.get()
valueLane.set("john");
console.log(oldvalue)
client.close()
Im trying to work with value lane. above is the client code. When i run the code the old value comeslink watched info change to john from Value.absent()
). Am i missing anything here. i can see the old and new value in the server side log
console.log(oldvalue)
returns Absent {}
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