@dazn/kopytko-framework 1.3.4 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -93,14 +93,14 @@ function StoreFacade() as Object
|
|
|
93
93
|
end for
|
|
94
94
|
end sub
|
|
95
95
|
|
|
96
|
-
prototype.subscribeOnce = sub (key as String, callback as Function)
|
|
96
|
+
prototype.subscribeOnce = sub (key as String, callback as Function, context = Invalid as Object)
|
|
97
97
|
m._handleSubscriber(key)
|
|
98
|
-
m._subscriptions[m._getRandomizedKey(key)] = { key: key, callback: [callback], once: true }
|
|
98
|
+
m._subscriptions[m._getRandomizedKey(key)] = { key: key, callback: [callback], context: context, once: true }
|
|
99
99
|
end sub
|
|
100
100
|
|
|
101
|
-
prototype.subscribe = sub (key as String, callback as Function)
|
|
101
|
+
prototype.subscribe = sub (key as String, callback as Function, context = Invalid as Object)
|
|
102
102
|
m._handleSubscriber(key)
|
|
103
|
-
m._subscriptions[m._getRandomizedKey(key)] = { key: key, callback: [callback], once: false }
|
|
103
|
+
m._subscriptions[m._getRandomizedKey(key)] = { key: key, callback: [callback], context: context, once: false }
|
|
104
104
|
end sub
|
|
105
105
|
|
|
106
106
|
prototype.unsubscribe = sub (key as String, callback as Function)
|
|
@@ -144,7 +144,11 @@ function StoreFacade() as Object
|
|
|
144
144
|
listener = m._subscriptions[subscriptionKey]
|
|
145
145
|
|
|
146
146
|
if (listener <> Invalid AND listener.key = key)
|
|
147
|
-
listener.
|
|
147
|
+
if (listener.context = Invalid)
|
|
148
|
+
listener.callback[0](value)
|
|
149
|
+
else
|
|
150
|
+
listener.callback[0](value, listener.context)
|
|
151
|
+
end if
|
|
148
152
|
|
|
149
153
|
if (listener.once)
|
|
150
154
|
m._subscriptions.delete(subscriptionKey)
|