You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2017/08/08 08:55:15 UTC
[03/39] incubator-weex git commit: * [jsfm] change callbacks from
array to object
* [jsfm] change callbacks from array to object
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/acd5814a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/acd5814a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/acd5814a
Branch: refs/heads/0.16-dev
Commit: acd5814a8e64f6cc1dff52b9c5333867d5107570
Parents: 769167a
Author: Hanks <zh...@gmail.com>
Authored: Wed Jul 26 16:03:57 2017 +0800
Committer: Hanks <zh...@gmail.com>
Committed: Wed Jul 26 16:03:57 2017 +0800
----------------------------------------------------------------------
html5/runtime/callback-manager.js | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/acd5814a/html5/runtime/callback-manager.js
----------------------------------------------------------------------
diff --git a/html5/runtime/callback-manager.js b/html5/runtime/callback-manager.js
index a83f034..84a40f2 100644
--- a/html5/runtime/callback-manager.js
+++ b/html5/runtime/callback-manager.js
@@ -28,7 +28,7 @@ export default class CallbackManager {
constructor (instanceId) {
this.instanceId = instanceId
this.lastCallbackId = 0
- this.callbacks = []
+ this.callbacks = {}
}
add (callback) {
this.lastCallbackId++
@@ -37,13 +37,13 @@ export default class CallbackManager {
}
remove (callbackId) {
const callback = this.callbacks[callbackId]
- this.callbacks[callbackId] = undefined
+ delete this.callbacks[callbackId]
return callback
}
consume (callbackId, data, ifKeepAlive) {
const callback = this.callbacks[callbackId]
if (typeof ifKeepAlive === 'undefined' || ifKeepAlive === false) {
- this.callbacks[callbackId] = undefined
+ delete this.callbacks[callbackId]
}
if (typeof callback === 'function') {
return callback(data)
@@ -51,6 +51,6 @@ export default class CallbackManager {
return new Error(`invalid callback id "${callbackId}"`)
}
close () {
- this.callbacks = this.callbacks.map(cb => undefined)
+ this.callbacks = {}
}
}