# HG changeset patch # User Edouard Tisserant # Date 1663832558 -7200 # Node ID 770c613c424ffe2c8f9b3f0ebe601cbca6c49d1d # Parent 0237c28cd1721e1a9c6ee63ba1e7cb489da7a758 SVGHMI: remove intermediate "updates" Map and apply_updates() It was used initially to decouple DOM updates from reception of data through websocket, but now since all widget SHOULD use animate() to modify DOM, and dispatch() only change internal state, apply_update is unnecessary. diff -r 0237c28cd172 -r 770c613c424f svghmi/svghmi.js --- a/svghmi/svghmi.js Wed Sep 21 11:51:05 2022 +0200 +++ b/svghmi/svghmi.js Thu Sep 22 09:42:38 2022 +0200 @@ -46,14 +46,6 @@ } }; -// Apply updates recieved through ws.onmessage to subscribed widgets -function apply_updates() { - updates.forEach((value, index) => { - dispatch_value(index, value); - }); - updates.clear(); -} - // Called on requestAnimationFrame, modifies DOM var requestAnimationFrameID = null; function animate() { @@ -126,14 +118,13 @@ if(iectype != undefined){ let dvgetter = dvgetters[iectype]; let [value, bytesize] = dvgetter(dv,i); - updates.set(index, value); + dispatch_value(index, value); i += bytesize; } else { throw new Error("Unknown index "+index); } }; - apply_updates(); // register for rendering on next frame, since there are updates } catch(err) { // 1003 is for "Unsupported Data" diff -r 0237c28cd172 -r 770c613c424f svghmi/widgets_common.ysl2 --- a/svghmi/widgets_common.ysl2 Wed Sep 21 11:51:05 2022 +0200 +++ b/svghmi/widgets_common.ysl2 Thu Sep 22 09:42:38 2022 +0200 @@ -189,7 +189,6 @@ ]); var persistent_indexes = new Map(); var cache = hmitree_types.map(_ignored => undefined); - var updates = new Map(); function page_local_index(varname, pagename){ let pagevars = hmi_locals[pagename]; @@ -209,7 +208,6 @@ let defaultval = local_defaults[varname]; if(defaultval != undefined) { cache[new_index] = defaultval; - updates.set(new_index, defaultval); if(persistent_locals.has(varname)) persistent_indexes.set(new_index, varname); }