summaryrefslogtreecommitdiffstats
path: root/webapp/src/main.js
diff options
context:
space:
mode:
authorUdo Walter2019-02-23 01:16:42 +0100
committerUdo Walter2019-02-23 01:16:42 +0100
commit3bef583ba90f20d314f5973ef2521e9cfa2828c7 (patch)
treecf51f0adad42ec132fd1dccf40113e293f4c28ce /webapp/src/main.js
parent[webapp/datatable] Fix something. I really have no idea how to describe this ... (diff)
downloadbas-3bef583ba90f20d314f5973ef2521e9cfa2828c7.tar.gz
bas-3bef583ba90f20d314f5973ef2521e9cfa2828c7.tar.xz
bas-3bef583ba90f20d314f5973ef2521e9cfa2828c7.zip
[webapp/datatable] code cleanup
Diffstat (limited to 'webapp/src/main.js')
-rw-r--r--webapp/src/main.js21
1 files changed, 12 insertions, 9 deletions
diff --git a/webapp/src/main.js b/webapp/src/main.js
index a87aae8..cc53b76 100644
--- a/webapp/src/main.js
+++ b/webapp/src/main.js
@@ -94,20 +94,23 @@ Vue.prototype.$snackbar = function (data) {
}
// Loop that processes work in chunks to allow the UI to refresh inbetween and prevents freezing.
-Vue.prototype.$loop = function (count, chunksize, callback, breakLoop = () => false, finished = () => {}) {
- var i = 0;
- (function chunk () {
+Vue.prototype.$loop = function (count, chunksize, iteration, callback = () => {}) {
+ var i = 0
+ var breakCondition = false
+ const chunk = () => {
+ if (breakCondition) return
var end = Math.min(i + chunksize, count)
for (; i < end; ++i) {
- callback(i)
+ iteration(i)
}
- let bl = breakLoop()
- if (i < count && !bl) {
+ if (i < count) {
setTimeout(chunk, 0)
- } else if (!bl) {
- finished()
+ } else {
+ callback()
}
- })()
+ }
+ chunk()
+ return { cancel: () => { breakCondition = true } }
}
new Vue({