Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.onEvent((body: Value) => {
if (format === "json") {
console.log(JSON.stringify(body.toAny()));
} else {
console.log(Recon.toString(body));
}
})
.didUnlink((downlink: client.Downlink) => {
protected onRemoteRemoveCharge(key: Value): void {
const view = this.view!;
if (key.getItem(0).equals(view.id)) {
return;
}
const id = Recon.toString(key);
view.setChildView(id, null);
}
protected onRemoteUpdateCharge(key: Value, value: Value): void {
const view = this.view!;
if (key.getItem(0).equals(view.id)) {
return;
}
const id = Recon.toString(key);
const t0 = value.get("t0").numberValue(Date.now());
const centerX = value.get("x").numberValue(Math.random());
const centerY = value.get("y").numberValue(Math.random());
const chargeRadius = value.get("r").numberValue(0);
if (!chargeRadius) {
return;
}
const color = value.get("color").stringValue("#00a6ed");
const tween = Transition.duration(300);
let charge = view.getChildView(id) as ChargeView | null;
if (charge) {
charge.t0 = t0;
charge.centerX.setState(centerX);
charge.centerY.setState(centerY);
charge.chargeColor(color, tween)
.chargeRadius(chargeRadius, tween)