Fixes performance killing potential bug with VueUi (#5199)

So apparently when conditions are right it could make infinite loop (client push -> server receive -> server push -> client receive -> client push...) killing client and server performance.

  <vui-button> now pushes data as JSON, this preserves data structure of parameters
  Store now won't allow state to be pushed if it was very recently received
  There was a plausibly for vueui/Topic() to push data twice, hindering performance. This was mitigated by taking in to consideration object Topic return value if data should pushed.
  Separated some code in to separate file for future reusal or programical uses.
This commit is contained in:
Karolis
2018-09-02 17:01:14 +03:00
committed by Erki
parent c90519f570
commit 8e5c762928
4 changed files with 41 additions and 24 deletions

12
vueui/src/utils.js Normal file
View File

@@ -0,0 +1,12 @@
import Store from './store.js'
export default {
sendToTopic(data, pushState = false) {
var r = new XMLHttpRequest()
var sendUrl = "?src=" + Store.state.uiref + "&vueuihrefjson=" + encodeURIComponent(JSON.stringify(data))
if (pushState) {
sendUrl += "&" + Store.getStatePushString()
}
r.open("GET", sendUrl, true);
r.send()
}
}