message_bus 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of message_bus might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG +5 -0
- data/assets/message-bus.js +17 -5
- data/lib/message_bus/version.rb +1 -1
- data/vendor/assets/javascripts/message-bus.js +17 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef40442bfe83abc9cd8b0a7be99fcb4e27f76a56
|
4
|
+
data.tar.gz: cfb98a433dd8a32d7dc405ec4e95c59297046bae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c8a9b6a258c7dbdbc35b3b675a3b67b278060a95249f8c2ac8de3a1761654941a7251e62267901ecb75ae8af7bb6fd6c08c3a6e5b4ff74f41325bcdd9ea3960
|
7
|
+
data.tar.gz: 401b34231fc26a549cb4443e7306b9675b1457d07ec717375882a58818d74f418350441421381b6d055d64774703d1d9e462892e9d0585adc139cf847e0617cb
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
23-09-2014
|
2
|
+
- Version 1.0.1
|
3
|
+
- Feature: $.ajax dependency can be passed in.
|
4
|
+
- Feature: unsubscribe accepts a second param for the function to unsubscribe.
|
5
|
+
|
1
6
|
22-09-2014
|
2
7
|
- Version 1.0.0
|
3
8
|
- Feature: add backgroundCallbackInterval - interval to send polls when page is in the background
|
data/assets/message-bus.js
CHANGED
@@ -59,8 +59,8 @@ window.MessageBus = (function() {
|
|
59
59
|
var aborted = false;
|
60
60
|
lastAjax = new Date();
|
61
61
|
totalAjaxCalls += 1;
|
62
|
-
|
63
|
-
return
|
62
|
+
|
63
|
+
return me.ajax({
|
64
64
|
url: me.baseUrl + "message-bus/" + me.clientId + "/poll?" + (!shouldLongPoll() || !me.enableLongPolling ? "dlp=t" : ""),
|
65
65
|
data: data,
|
66
66
|
cache: false,
|
@@ -145,6 +145,9 @@ window.MessageBus = (function() {
|
|
145
145
|
clientId: clientId,
|
146
146
|
alwaysLongPoll: false,
|
147
147
|
baseUrl: baseUrl,
|
148
|
+
// TODO we can make the dependency on $ and jQuery conditional
|
149
|
+
// all we really need is an implementation of ajax
|
150
|
+
ajax: $.ajax,
|
148
151
|
|
149
152
|
diagnostics: function(){
|
150
153
|
console.log("Stopped: " + stopped + " Started: " + started);
|
@@ -227,7 +230,7 @@ window.MessageBus = (function() {
|
|
227
230
|
},
|
228
231
|
|
229
232
|
// Unsubscribe from a channel
|
230
|
-
unsubscribe: function(channel) {
|
233
|
+
unsubscribe: function(channel, func) {
|
231
234
|
// TODO proper globbing
|
232
235
|
var glob;
|
233
236
|
if (channel.indexOf("*", channel.length - 1) !== -1) {
|
@@ -235,12 +238,21 @@ window.MessageBus = (function() {
|
|
235
238
|
glob = true;
|
236
239
|
}
|
237
240
|
callbacks = $.grep(callbacks,function(callback) {
|
241
|
+
var keep;
|
242
|
+
|
238
243
|
if (glob) {
|
239
|
-
|
244
|
+
keep = callback.channel.substr(0, channel.length) !== channel;
|
240
245
|
} else {
|
241
|
-
|
246
|
+
keep = callback.channel !== channel;
|
247
|
+
}
|
248
|
+
|
249
|
+
if(!keep && func && callback.func !== func){
|
250
|
+
keep = true;
|
242
251
|
}
|
252
|
+
|
253
|
+
return keep;
|
243
254
|
});
|
255
|
+
|
244
256
|
if (me.longPoll) {
|
245
257
|
return me.longPoll.abort();
|
246
258
|
}
|
data/lib/message_bus/version.rb
CHANGED
@@ -59,8 +59,8 @@ window.MessageBus = (function() {
|
|
59
59
|
var aborted = false;
|
60
60
|
lastAjax = new Date();
|
61
61
|
totalAjaxCalls += 1;
|
62
|
-
|
63
|
-
return
|
62
|
+
|
63
|
+
return me.ajax({
|
64
64
|
url: me.baseUrl + "message-bus/" + me.clientId + "/poll?" + (!shouldLongPoll() || !me.enableLongPolling ? "dlp=t" : ""),
|
65
65
|
data: data,
|
66
66
|
cache: false,
|
@@ -145,6 +145,9 @@ window.MessageBus = (function() {
|
|
145
145
|
clientId: clientId,
|
146
146
|
alwaysLongPoll: false,
|
147
147
|
baseUrl: baseUrl,
|
148
|
+
// TODO we can make the dependency on $ and jQuery conditional
|
149
|
+
// all we really need is an implementation of ajax
|
150
|
+
ajax: $.ajax,
|
148
151
|
|
149
152
|
diagnostics: function(){
|
150
153
|
console.log("Stopped: " + stopped + " Started: " + started);
|
@@ -227,7 +230,7 @@ window.MessageBus = (function() {
|
|
227
230
|
},
|
228
231
|
|
229
232
|
// Unsubscribe from a channel
|
230
|
-
unsubscribe: function(channel) {
|
233
|
+
unsubscribe: function(channel, func) {
|
231
234
|
// TODO proper globbing
|
232
235
|
var glob;
|
233
236
|
if (channel.indexOf("*", channel.length - 1) !== -1) {
|
@@ -235,12 +238,21 @@ window.MessageBus = (function() {
|
|
235
238
|
glob = true;
|
236
239
|
}
|
237
240
|
callbacks = $.grep(callbacks,function(callback) {
|
241
|
+
var keep;
|
242
|
+
|
238
243
|
if (glob) {
|
239
|
-
|
244
|
+
keep = callback.channel.substr(0, channel.length) !== channel;
|
240
245
|
} else {
|
241
|
-
|
246
|
+
keep = callback.channel !== channel;
|
247
|
+
}
|
248
|
+
|
249
|
+
if(!keep && func && callback.func !== func){
|
250
|
+
keep = true;
|
242
251
|
}
|
252
|
+
|
253
|
+
return keep;
|
243
254
|
});
|
255
|
+
|
244
256
|
if (me.longPoll) {
|
245
257
|
return me.longPoll.abort();
|
246
258
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: message_bus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|