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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 540d941673f27bbce348815bdc0e76b5dda46f54
4
- data.tar.gz: 7497c9ff05c2c0752f40dd4e11fe892fecaef57e
3
+ metadata.gz: ef40442bfe83abc9cd8b0a7be99fcb4e27f76a56
4
+ data.tar.gz: cfb98a433dd8a32d7dc405ec4e95c59297046bae
5
5
  SHA512:
6
- metadata.gz: 3d139e29977062c4072488a6b3d49dbf3795aa7d0a2ffedb51d80f6b7f5a0b73d432a7d2d467a1a0e70fc57accd1d8214cb5245e8864c7eadb846d298257c1f7
7
- data.tar.gz: 29913ebc677903bc51f89e94b01ae1c357b349ba154615131dfd682ee26007bcf59f7cf2bca22fae54ec766822913b4c5391118397fb8f5dec8e4bdf433f32e0
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
@@ -59,8 +59,8 @@ window.MessageBus = (function() {
59
59
  var aborted = false;
60
60
  lastAjax = new Date();
61
61
  totalAjaxCalls += 1;
62
-
63
- return $.ajax({
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
- return callback.channel.substr(0, channel.length) !== channel;
244
+ keep = callback.channel.substr(0, channel.length) !== channel;
240
245
  } else {
241
- return callback.channel !== channel;
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
  }
@@ -1,3 +1,3 @@
1
1
  module MessageBus
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -59,8 +59,8 @@ window.MessageBus = (function() {
59
59
  var aborted = false;
60
60
  lastAjax = new Date();
61
61
  totalAjaxCalls += 1;
62
-
63
- return $.ajax({
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
- return callback.channel.substr(0, channel.length) !== channel;
244
+ keep = callback.channel.substr(0, channel.length) !== channel;
240
245
  } else {
241
- return callback.channel !== channel;
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.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-22 00:00:00.000000000 Z
11
+ date: 2014-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack