rxjs-rails 2.2.18 → 2.2.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad6926d878a710463b0f98d6edcc1fb22302a262
4
- data.tar.gz: 11e4e2d1b76ced98f379f1979d79a262e3c3e9ff
3
+ metadata.gz: ca12b7cac3d584e7ae7333c48c6a9f0eb4c8365c
4
+ data.tar.gz: 1417d47add82b99aa3d7795e0fd01a9e05c3e4de
5
5
  SHA512:
6
- metadata.gz: 25e96c012d8f421ea49fa9a8a59750607eb2b7807fe97ea479df19669f57c53d7fdac80a36df3593f27e4893d59df91d992b0e3639506c91f8ce44455fddcdbf
7
- data.tar.gz: fcb0683865bf89fa153a269d89a0e30be0c41c9727ff3542fe284a08a628d9d46eae6978ffdf6a967f6b12c43bcdd8619b47b9a3596f678b61260bbf112c0a49
6
+ metadata.gz: 706f784ad10ceef8cad344b47f33050008c81e6da1f7e4e02b90d3aa0a92b9d31f7663094772b2c4ad107c9faefaba18a57023aa32383aaad541aa03af9790fd
7
+ data.tar.gz: f55b4c6143f62d22e2a8f0e684ac0f95a319dc16a47330c89a596ec50ac973b80d97adb9f7be004ca430cdf50830ab2aa59913221cbe4e74ea985849718976b7
@@ -1,6 +1,6 @@
1
1
  module Rxjs
2
2
  module Rails
3
- VERSION = "2.2.18"
3
+ VERSION = "2.2.19"
4
4
  end
5
5
  end
6
6
 
@@ -38,22 +38,14 @@
38
38
  observableProto = Observable.prototype,
39
39
  CompositeDisposable = Rx.CompositeDisposable,
40
40
  AnonymousObservable = Rx.AnonymousObservable,
41
- isEqual = Rx.internals.isEqual;
41
+ isEqual = Rx.internals.isEqual,
42
+ defaultComparer = Rx.helpers.defaultComparer,
43
+ identity = Rx.helpers.identity,
44
+ subComparer = Rx.helpers.defaultSubComparer;
42
45
 
43
46
  // Defaults
44
47
  var argumentOutOfRange = 'Argument out of range';
45
48
  var sequenceContainsNoElements = "Sequence contains no elements.";
46
- function defaultComparer(x, y) { return isEqual(x, y); }
47
- function identity(x) { return x; }
48
- function subComparer(x, y) {
49
- if (x > y) {
50
- return 1;
51
- }
52
- if (x < y) {
53
- return -1
54
- }
55
- return 0;
56
- }
57
49
 
58
50
  function extremaBy(source, keySelector, comparer) {
59
51
  return new AnonymousObservable(function (observer) {
@@ -1 +1 @@
1
- (function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx","exports"],function(b,d){return c.Rx=a(c,d,b),c.Rx}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c,d){function e(a,b){return t(a,b)}function f(a){return a}function g(a,b){return a>b?1:b>a?-1:0}function h(a,b,c){return new s(function(d){var e=!1,f=null,g=[];return a.subscribe(function(a){var h,i;try{i=b(a)}catch(j){return void d.onError(j)}if(h=0,e)try{h=c(i,f)}catch(k){return void d.onError(k)}else e=!0,f=i;h>0&&(f=i,g=[]),h>=0&&g.push(a)},d.onError.bind(d),function(){d.onNext(g),d.onCompleted()})})}function i(a){if(0===a.length)throw new Error(v);return a[0]}function j(a,b,c){return new s(function(d){var e=0,f=b.length;return a.subscribe(function(a){var g=!1;try{f>e&&(g=c(a,b[e++]))}catch(h){return void d.onError(h)}g||(d.onNext(!1),d.onCompleted())},d.onError.bind(d),function(){d.onNext(e===f),d.onCompleted()})})}function k(a,b,c,d){if(0>b)throw new Error(u);return new s(function(e){var f=b;return a.subscribe(function(a){0===f&&(e.onNext(a),e.onCompleted()),f--},e.onError.bind(e),function(){c?(e.onNext(d),e.onCompleted()):e.onError(new Error(u))})})}function l(a,b,c){return new s(function(d){var e=c,f=!1;return a.subscribe(function(a){f?d.onError(new Error("Sequence contains more than one element")):(e=a,f=!0)},d.onError.bind(d),function(){f||b?(d.onNext(e),d.onCompleted()):d.onError(new Error(v))})})}function m(a,b,c){return new s(function(d){return a.subscribe(function(a){d.onNext(a),d.onCompleted()},d.onError.bind(d),function(){b?(d.onNext(c),d.onCompleted()):d.onError(new Error(v))})})}function n(a,b,c){return new s(function(d){var e=c,f=!1;return a.subscribe(function(a){e=a,f=!0},d.onError.bind(d),function(){f||b?(d.onNext(e),d.onCompleted()):d.onError(new Error(v))})})}function o(a,b,c,e){return new s(function(f){var g=0;return a.subscribe(function(d){var h;try{h=b.call(c,d,g,a)}catch(i){return void f.onError(i)}h?(f.onNext(e?g:d),f.onCompleted()):g++},f.onError.bind(f),function(){f.onNext(e?-1:d),f.onCompleted()})})}var p=c.Observable,q=p.prototype,r=c.CompositeDisposable,s=c.AnonymousObservable,t=c.internals.isEqual,u="Argument out of range",v="Sequence contains no elements.";return q.aggregate=function(){var a,b,c;return 2===arguments.length?(a=arguments[0],b=!0,c=arguments[1]):c=arguments[0],b?this.scan(a,c).startWith(a).finalValue():this.scan(c).finalValue()},q.reduce=function(a){var b,c;return 2===arguments.length&&(c=!0,b=arguments[1]),c?this.scan(b,a).startWith(b).finalValue():this.scan(a).finalValue()},q.some=q.any=function(a,b){var c=this;return a?c.where(a,b).any():new s(function(a){return c.subscribe(function(){a.onNext(!0),a.onCompleted()},a.onError.bind(a),function(){a.onNext(!1),a.onCompleted()})})},q.isEmpty=function(){return this.any().select(function(a){return!a})},q.every=q.all=function(a,b){return this.where(function(b){return!a(b)},b).any().select(function(a){return!a})},q.contains=function(a,b){return b||(b=e),this.where(function(c){return b(c,a)}).any()},q.count=function(a,b){return a?this.where(a,b).count():this.aggregate(0,function(a){return a+1})},q.sum=function(a,b){return a?this.select(a,b).sum():this.aggregate(0,function(a,b){return a+b})},q.minBy=function(a,b){return b||(b=g),h(this,a,function(a,c){return-1*b(a,c)})},q.min=function(a){return this.minBy(f,a).select(function(a){return i(a)})},q.maxBy=function(a,b){return b||(b=g),h(this,a,b)},q.max=function(a){return this.maxBy(f,a).select(function(a){return i(a)})},q.average=function(a,b){return a?this.select(a,b).average():this.scan({sum:0,count:0},function(a,b){return{sum:a.sum+b,count:a.count+1}}).finalValue().select(function(a){if(0===a.count)throw new Error("The input sequence was empty");return a.sum/a.count})},q.sequenceEqual=function(a,b){var c=this;return b||(b=e),Array.isArray(a)?j(c,a,b):new s(function(d){var e=!1,f=!1,g=[],h=[],i=c.subscribe(function(a){var c,e;if(h.length>0){e=h.shift();try{c=b(e,a)}catch(i){return void d.onError(i)}c||(d.onNext(!1),d.onCompleted())}else f?(d.onNext(!1),d.onCompleted()):g.push(a)},d.onError.bind(d),function(){e=!0,0===g.length&&(h.length>0?(d.onNext(!1),d.onCompleted()):f&&(d.onNext(!0),d.onCompleted()))}),j=a.subscribe(function(a){var c,f;if(g.length>0){f=g.shift();try{c=b(f,a)}catch(i){return void d.onError(i)}c||(d.onNext(!1),d.onCompleted())}else e?(d.onNext(!1),d.onCompleted()):h.push(a)},d.onError.bind(d),function(){f=!0,0===h.length&&(g.length>0?(d.onNext(!1),d.onCompleted()):e&&(d.onNext(!0),d.onCompleted()))});return new r(i,j)})},q.elementAt=function(a){return k(this,a,!1)},q.elementAtOrDefault=function(a,b){return k(this,a,!0,b)},q.single=function(a,b){return a?this.where(a,b).single():l(this,!1)},q.singleOrDefault=function(a,b,c){return a?this.where(a,c).singleOrDefault(null,b):l(this,!0,b)},q.first=function(a,b){return a?this.where(a,b).first():m(this,!1)},q.firstOrDefault=function(a,b){return a?this.where(a).firstOrDefault(null,b):m(this,!0,b)},q.last=function(a,b){return a?this.where(a,b).last():n(this,!1)},q.lastOrDefault=function(a,b,c){return a?this.where(a,c).lastOrDefault(null,b):n(this,!0,b)},q.find=function(a,b){return o(this,a,b,!1)},q.findIndex=function(a,b){return o(this,a,b,!0)},c});
1
+ (function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx","exports"],function(b,d){return c.Rx=a(c,d,b),c.Rx}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c,d){function e(a,b,c){return new p(function(d){var e=!1,f=null,g=[];return a.subscribe(function(a){var h,i;try{i=b(a)}catch(j){return void d.onError(j)}if(h=0,e)try{h=c(i,f)}catch(k){return void d.onError(k)}else e=!0,f=i;h>0&&(f=i,g=[]),h>=0&&g.push(a)},d.onError.bind(d),function(){d.onNext(g),d.onCompleted()})})}function f(a){if(0===a.length)throw new Error(u);return a[0]}function g(a,b,c){return new p(function(d){var e=0,f=b.length;return a.subscribe(function(a){var g=!1;try{f>e&&(g=c(a,b[e++]))}catch(h){return void d.onError(h)}g||(d.onNext(!1),d.onCompleted())},d.onError.bind(d),function(){d.onNext(e===f),d.onCompleted()})})}function h(a,b,c,d){if(0>b)throw new Error(t);return new p(function(e){var f=b;return a.subscribe(function(a){0===f&&(e.onNext(a),e.onCompleted()),f--},e.onError.bind(e),function(){c?(e.onNext(d),e.onCompleted()):e.onError(new Error(t))})})}function i(a,b,c){return new p(function(d){var e=c,f=!1;return a.subscribe(function(a){f?d.onError(new Error("Sequence contains more than one element")):(e=a,f=!0)},d.onError.bind(d),function(){f||b?(d.onNext(e),d.onCompleted()):d.onError(new Error(u))})})}function j(a,b,c){return new p(function(d){return a.subscribe(function(a){d.onNext(a),d.onCompleted()},d.onError.bind(d),function(){b?(d.onNext(c),d.onCompleted()):d.onError(new Error(u))})})}function k(a,b,c){return new p(function(d){var e=c,f=!1;return a.subscribe(function(a){e=a,f=!0},d.onError.bind(d),function(){f||b?(d.onNext(e),d.onCompleted()):d.onError(new Error(u))})})}function l(a,b,c,e){return new p(function(f){var g=0;return a.subscribe(function(d){var h;try{h=b.call(c,d,g,a)}catch(i){return void f.onError(i)}h?(f.onNext(e?g:d),f.onCompleted()):g++},f.onError.bind(f),function(){f.onNext(e?-1:d),f.onCompleted()})})}var m=c.Observable,n=m.prototype,o=c.CompositeDisposable,p=c.AnonymousObservable,q=(c.internals.isEqual,c.helpers.defaultComparer),r=c.helpers.identity,s=c.helpers.defaultSubComparer,t="Argument out of range",u="Sequence contains no elements.";return n.aggregate=function(){var a,b,c;return 2===arguments.length?(a=arguments[0],b=!0,c=arguments[1]):c=arguments[0],b?this.scan(a,c).startWith(a).finalValue():this.scan(c).finalValue()},n.reduce=function(a){var b,c;return 2===arguments.length&&(c=!0,b=arguments[1]),c?this.scan(b,a).startWith(b).finalValue():this.scan(a).finalValue()},n.some=n.any=function(a,b){var c=this;return a?c.where(a,b).any():new p(function(a){return c.subscribe(function(){a.onNext(!0),a.onCompleted()},a.onError.bind(a),function(){a.onNext(!1),a.onCompleted()})})},n.isEmpty=function(){return this.any().select(function(a){return!a})},n.every=n.all=function(a,b){return this.where(function(b){return!a(b)},b).any().select(function(a){return!a})},n.contains=function(a,b){return b||(b=q),this.where(function(c){return b(c,a)}).any()},n.count=function(a,b){return a?this.where(a,b).count():this.aggregate(0,function(a){return a+1})},n.sum=function(a,b){return a?this.select(a,b).sum():this.aggregate(0,function(a,b){return a+b})},n.minBy=function(a,b){return b||(b=s),e(this,a,function(a,c){return-1*b(a,c)})},n.min=function(a){return this.minBy(r,a).select(function(a){return f(a)})},n.maxBy=function(a,b){return b||(b=s),e(this,a,b)},n.max=function(a){return this.maxBy(r,a).select(function(a){return f(a)})},n.average=function(a,b){return a?this.select(a,b).average():this.scan({sum:0,count:0},function(a,b){return{sum:a.sum+b,count:a.count+1}}).finalValue().select(function(a){if(0===a.count)throw new Error("The input sequence was empty");return a.sum/a.count})},n.sequenceEqual=function(a,b){var c=this;return b||(b=q),Array.isArray(a)?g(c,a,b):new p(function(d){var e=!1,f=!1,g=[],h=[],i=c.subscribe(function(a){var c,e;if(h.length>0){e=h.shift();try{c=b(e,a)}catch(i){return void d.onError(i)}c||(d.onNext(!1),d.onCompleted())}else f?(d.onNext(!1),d.onCompleted()):g.push(a)},d.onError.bind(d),function(){e=!0,0===g.length&&(h.length>0?(d.onNext(!1),d.onCompleted()):f&&(d.onNext(!0),d.onCompleted()))}),j=a.subscribe(function(a){var c,f;if(g.length>0){f=g.shift();try{c=b(f,a)}catch(i){return void d.onError(i)}c||(d.onNext(!1),d.onCompleted())}else e?(d.onNext(!1),d.onCompleted()):h.push(a)},d.onError.bind(d),function(){f=!0,0===h.length&&(g.length>0?(d.onNext(!1),d.onCompleted()):e&&(d.onNext(!0),d.onCompleted()))});return new o(i,j)})},n.elementAt=function(a){return h(this,a,!1)},n.elementAtOrDefault=function(a,b){return h(this,a,!0,b)},n.single=function(a,b){return a?this.where(a,b).single():i(this,!1)},n.singleOrDefault=function(a,b,c){return a?this.where(a,c).singleOrDefault(null,b):i(this,!0,b)},n.first=function(a,b){return a?this.where(a,b).first():j(this,!1)},n.firstOrDefault=function(a,b){return a?this.where(a).firstOrDefault(null,b):j(this,!0,b)},n.last=function(a,b){return a?this.where(a,b).last():k(this,!1)},n.lastOrDefault=function(a,b,c){return a?this.where(a,c).lastOrDefault(null,b):k(this,!0,b)},n.find=function(a,b){return l(this,a,b,!1)},n.findIndex=function(a,b){return l(this,a,b,!0)},c});
@@ -191,168 +191,190 @@
191
191
  };
192
192
  };
193
193
 
194
- function fixEvent(event) {
195
- var stopPropagation = function () {
196
- this.cancelBubble = true;
197
- };
194
+ function fixEvent(event) {
195
+ var stopPropagation = function () {
196
+ this.cancelBubble = true;
197
+ };
198
198
 
199
- var preventDefault = function () {
200
- this.bubbledKeyCode = this.keyCode;
201
- if (this.ctrlKey) {
202
- try {
203
- this.keyCode = 0;
204
- } catch (e) { }
205
- }
206
- this.defaultPrevented = true;
207
- this.returnValue = false;
208
- this.modified = true;
209
- };
199
+ var preventDefault = function () {
200
+ this.bubbledKeyCode = this.keyCode;
201
+ if (this.ctrlKey) {
202
+ try {
203
+ this.keyCode = 0;
204
+ } catch (e) { }
205
+ }
206
+ this.defaultPrevented = true;
207
+ this.returnValue = false;
208
+ this.modified = true;
209
+ };
210
210
 
211
- event || (event = window.event);
212
- if (!event.target) {
213
- event.target = event.target || event.srcElement;
211
+ event || (event = root.event);
212
+ if (!event.target) {
213
+ event.target = event.target || event.srcElement;
214
214
 
215
- if (event.type == 'mouseover') {
216
- event.relatedTarget = event.fromElement;
217
- }
218
- if (event.type == 'mouseout') {
219
- event.relatedTarget = event.toElement;
220
- }
221
- // Adding stopPropogation and preventDefault to IE
222
- if (!event.stopPropagation){
223
- event.stopPropagation = stopPropagation;
224
- event.preventDefault = preventDefault;
225
- }
226
- // Normalize key events
227
- switch(event.type){
228
- case 'keypress':
229
- var c = ('charCode' in event ? event.charCode : event.keyCode);
230
- if (c == 10) {
231
- c = 0;
232
- event.keyCode = 13;
233
- } else if (c == 13 || c == 27) {
234
- c = 0;
235
- } else if (c == 3) {
236
- c = 99;
237
- }
238
- event.charCode = c;
239
- event.keyChar = event.charCode ? String.fromCharCode(event.charCode) : '';
240
- break;
241
- }
242
- }
215
+ if (event.type == 'mouseover') {
216
+ event.relatedTarget = event.fromElement;
217
+ }
218
+ if (event.type == 'mouseout') {
219
+ event.relatedTarget = event.toElement;
220
+ }
221
+ // Adding stopPropogation and preventDefault to IE
222
+ if (!event.stopPropagation){
223
+ event.stopPropagation = stopPropagation;
224
+ event.preventDefault = preventDefault;
225
+ }
226
+ // Normalize key events
227
+ switch(event.type){
228
+ case 'keypress':
229
+ var c = ('charCode' in event ? event.charCode : event.keyCode);
230
+ if (c == 10) {
231
+ c = 0;
232
+ event.keyCode = 13;
233
+ } else if (c == 13 || c == 27) {
234
+ c = 0;
235
+ } else if (c == 3) {
236
+ c = 99;
237
+ }
238
+ event.charCode = c;
239
+ event.keyChar = event.charCode ? String.fromCharCode(event.charCode) : '';
240
+ break;
241
+ }
242
+ }
243
+
244
+ return event;
245
+ }
243
246
 
244
- return event;
247
+ function createListener (element, name, handler) {
248
+ // Node.js specific
249
+ if (element.addListener) {
250
+ element.addListener(name, handler);
251
+ return disposableCreate(function () {
252
+ element.removeListener(name, handler);
253
+ });
254
+ }
255
+ // Standards compliant
256
+ if (element.addEventListener) {
257
+ element.addEventListener(name, handler, false);
258
+ return disposableCreate(function () {
259
+ element.removeEventListener(name, handler, false);
260
+ });
261
+ }
262
+ if (element.attachEvent) {
263
+ // IE Specific
264
+ var innerHandler = function (event) {
265
+ handler(fixEvent(event));
266
+ };
267
+ element.attachEvent('on' + name, innerHandler);
268
+ return disposableCreate(function () {
269
+ element.detachEvent('on' + name, innerHandler);
270
+ });
245
271
  }
272
+ // Level 1 DOM Events
273
+ element['on' + name] = handler;
274
+ return disposableCreate(function () {
275
+ element['on' + name] = null;
276
+ });
277
+ }
246
278
 
247
- function createListener (element, name, handler) {
248
- // Node.js specific
249
- if (element.addListener) {
250
- element.addListener(name, handler);
251
- return disposableCreate(function () {
252
- element.removeListener(name, handler);
253
- });
254
- }
255
- // Standards compliant
256
- if (element.addEventListener) {
257
- element.addEventListener(name, handler, false);
258
- return disposableCreate(function () {
259
- element.removeEventListener(name, handler, false);
260
- });
261
- } else if (element.attachEvent) {
262
- // IE Specific
263
- var innerHandler = function (event) {
264
- handler(fixEvent(event));
265
- };
266
- element.attachEvent('on' + name, innerHandler);
267
- return disposableCreate(function () {
268
- element.detachEvent('on' + name, innerHandler);
269
- });
270
- } else {
271
- // Level 1 DOM Events
272
- element['on' + name] = handler;
273
- return disposableCreate(function () {
274
- element['on' + name] = null;
275
- });
276
- }
279
+ function createEventListener (el, eventName, handler) {
280
+ var disposables = new CompositeDisposable();
281
+
282
+ // Asume NodeList
283
+ if (typeof el.item === 'function' && typeof el.length === 'number') {
284
+ for (var i = 0, len = el.length; i < len; i++) {
285
+ disposables.add(createEventListener(el.item(i), eventName, handler));
286
+ }
287
+ } else if (el) {
288
+ disposables.add(createListener(el, eventName, handler));
277
289
  }
278
290
 
279
- function createEventListener (el, eventName, handler) {
280
- var disposables = new CompositeDisposable();
291
+ return disposables;
292
+ }
281
293
 
282
- // Asume NodeList
283
- if (el && el.length) {
284
- for (var i = 0, len = el.length; i < len; i++) {
285
- disposables.add(createEventListener(el[i], eventName, handler));
286
- }
287
- } else if (el) {
288
- disposables.add(createListener(el, eventName, handler));
289
- }
294
+ // Check for Angular/jQuery/Zepto support
295
+ var jq =
296
+ !!root.angular && !!angular.element ? angular.element :
297
+ (!!root.jQuery ? root.jQuery : (
298
+ !!root.Zepto ? root.Zepto : null));
290
299
 
291
- return disposables;
292
- }
300
+ // Check for ember
301
+ var ember = !!root.Ember && typeof root.Ember.addListener === 'function';
293
302
 
294
- /**
295
- * Creates an observable sequence by adding an event listener to the matching DOMElement or each item in the NodeList.
296
- *
297
- * @example
298
- * var source = Rx.Observable.fromEvent(element, 'mouseup');
299
- *
300
- * @param {Object} element The DOMElement or NodeList to attach a listener.
301
- * @param {String} eventName The event name to attach the observable sequence.
302
- * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
303
- * @returns {Observable} An observable sequence of events from the specified element and the specified event.
304
- */
305
- Observable.fromEvent = function (element, eventName, selector) {
306
- return new AnonymousObservable(function (observer) {
307
- return createEventListener(
308
- element,
309
- eventName,
310
- function handler (e) {
311
- var results = e;
312
-
313
- if (selector) {
314
- try {
315
- results = selector(arguments);
316
- } catch (err) {
317
- observer.onError(err);
318
- return
319
- }
320
- }
303
+ /**
304
+ * Creates an observable sequence by adding an event listener to the matching DOMElement or each item in the NodeList.
305
+ *
306
+ * @example
307
+ * var source = Rx.Observable.fromEvent(element, 'mouseup');
308
+ *
309
+ * @param {Object} element The DOMElement or NodeList to attach a listener.
310
+ * @param {String} eventName The event name to attach the observable sequence.
311
+ * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
312
+ * @returns {Observable} An observable sequence of events from the specified element and the specified event.
313
+ */
314
+ Observable.fromEvent = function (element, eventName, selector) {
315
+ if (ember) {
316
+ return fromEventPattern(
317
+ function (h) { Ember.addListener(element, eventName); },
318
+ function (h) { Ember.removeListener(element, eventName); },
319
+ selector);
320
+ }
321
+ if (jq) {
322
+ var $elem = jq(elem);
323
+ return fromEventPattern(
324
+ function (h) { $elem.on(eventName, h); },
325
+ function (h) { $elem.off(eventName, h); },
326
+ selector);
327
+ }
328
+ return new AnonymousObservable(function (observer) {
329
+ return createEventListener(
330
+ element,
331
+ eventName,
332
+ function handler (e) {
333
+ var results = e;
321
334
 
322
- observer.onNext(results);
323
- });
324
- }).publish().refCount();
325
- };
326
- /**
327
- * Creates an observable sequence from an event emitter via an addHandler/removeHandler pair.
328
- * @param {Function} addHandler The function to add a handler to the emitter.
329
- * @param {Function} [removeHandler] The optional function to remove a handler from an emitter.
330
- * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
331
- * @returns {Observable} An observable sequence which wraps an event from an event emitter
332
- */
333
- Observable.fromEventPattern = function (addHandler, removeHandler, selector) {
334
- return new AnonymousObservable(function (observer) {
335
- function innerHandler (e) {
336
- var result = e;
337
- if (selector) {
338
- try {
339
- result = selector(arguments);
340
- } catch (err) {
341
- observer.onError(err);
342
- return;
343
- }
344
- }
345
- observer.onNext(result);
335
+ if (selector) {
336
+ try {
337
+ results = selector(arguments);
338
+ } catch (err) {
339
+ observer.onError(err);
340
+ return
346
341
  }
342
+ }
347
343
 
348
- var returnValue = addHandler(innerHandler);
349
- return disposableCreate(function () {
350
- if (removeHandler) {
351
- removeHandler(innerHandler, returnValue);
352
- }
353
- });
354
- }).publish().refCount();
355
- };
344
+ observer.onNext(results);
345
+ });
346
+ }).publish().refCount();
347
+ };
348
+ /**
349
+ * Creates an observable sequence from an event emitter via an addHandler/removeHandler pair.
350
+ * @param {Function} addHandler The function to add a handler to the emitter.
351
+ * @param {Function} [removeHandler] The optional function to remove a handler from an emitter.
352
+ * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
353
+ * @returns {Observable} An observable sequence which wraps an event from an event emitter
354
+ */
355
+ var fromEventPattern = Observable.fromEventPattern = function (addHandler, removeHandler, selector) {
356
+ return new AnonymousObservable(function (observer) {
357
+ function innerHandler (e) {
358
+ var result = e;
359
+ if (selector) {
360
+ try {
361
+ result = selector(arguments);
362
+ } catch (err) {
363
+ observer.onError(err);
364
+ return;
365
+ }
366
+ }
367
+ observer.onNext(result);
368
+ }
369
+
370
+ var returnValue = addHandler(innerHandler);
371
+ return disposableCreate(function () {
372
+ if (removeHandler) {
373
+ removeHandler(innerHandler, returnValue);
374
+ }
375
+ });
376
+ }).publish().refCount();
377
+ };
356
378
 
357
379
  /**
358
380
  * Invokes the asynchronous function, surfacing the result through an observable sequence.
@@ -1 +1 @@
1
- (function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx.binding","exports"],function(b,d){return c.Rx=a(c,d,b),c.Rx}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c){function d(a){var b=function(){this.cancelBubble=!0},c=function(){if(this.bubbledKeyCode=this.keyCode,this.ctrlKey)try{this.keyCode=0}catch(a){}this.defaultPrevented=!0,this.returnValue=!1,this.modified=!0};if(a||(a=window.event),!a.target)switch(a.target=a.target||a.srcElement,"mouseover"==a.type&&(a.relatedTarget=a.fromElement),"mouseout"==a.type&&(a.relatedTarget=a.toElement),a.stopPropagation||(a.stopPropagation=b,a.preventDefault=c),a.type){case"keypress":var d="charCode"in a?a.charCode:a.keyCode;10==d?(d=0,a.keyCode=13):13==d||27==d?d=0:3==d&&(d=99),a.charCode=d,a.keyChar=a.charCode?String.fromCharCode(a.charCode):""}return a}function e(a,b,c){if(a.addListener)return a.addListener(b,c),l(function(){a.removeListener(b,c)});if(a.addEventListener)return a.addEventListener(b,c,!1),l(function(){a.removeEventListener(b,c,!1)});if(a.attachEvent){var e=function(a){c(d(a))};return a.attachEvent("on"+b,e),l(function(){a.detachEvent("on"+b,e)})}return a["on"+b]=c,l(function(){a["on"+b]=null})}function f(a,b,c){var d=new m;if(a&&a.length)for(var g=0,h=a.length;h>g;g++)d.add(f(a[g],b,c));else a&&d.add(e(a,b,c));return d}var g=c.Observable,h=(g.prototype,g.fromPromise),i=g.throwException,j=c.AnonymousObservable,k=c.AsyncSubject,l=c.Disposable.create,m=c.CompositeDisposable,n=c.Scheduler.immediate,o=Array.prototype.slice;g.start=function(a,b,c){return p(a,b,c)()};var p=g.toAsync=function(a,b,c){return b||(b=timeoutScheduler),function(){var d=arguments,e=new k;return b.schedule(function(){var b;try{b=a.apply(c,d)}catch(f){return void e.onError(f)}e.onNext(b),e.onCompleted()}),e.asObservable()}};return g.fromCallback=function(a,b,c,d){return b||(b=n),function(){var e=o.call(arguments,0);return new j(function(f){return b.schedule(function(){function b(a){var b=a;if(d)try{b=d(arguments)}catch(c){return void f.onError(c)}else 1===b.length&&(b=b[0]);f.onNext(b),f.onCompleted()}e.push(b),a.apply(c,e)})})}},g.fromNodeCallback=function(a,b,c,d){return b||(b=n),function(){var e=o.call(arguments,0);return new j(function(f){return b.schedule(function(){function b(a){if(a)return void f.onError(a);var b=o.call(arguments,1);if(d)try{b=d(b)}catch(c){return void f.onError(c)}else 1===b.length&&(b=b[0]);f.onNext(b),f.onCompleted()}e.push(b),a.apply(c,e)})})}},g.fromEvent=function(a,b,c){return new j(function(d){return f(a,b,function(a){var b=a;if(c)try{b=c(arguments)}catch(e){return void d.onError(e)}d.onNext(b)})}).publish().refCount()},g.fromEventPattern=function(a,b,c){return new j(function(d){function e(a){var b=a;if(c)try{b=c(arguments)}catch(e){return void d.onError(e)}d.onNext(b)}var f=a(e);return l(function(){b&&b(e,f)})}).publish().refCount()},g.startAsync=function(a){var b;try{b=a()}catch(c){return i(c)}return h(b)},c});
1
+ (function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx.binding","exports"],function(b,d){return c.Rx=a(c,d,b),c.Rx}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c){function d(b){var c=function(){this.cancelBubble=!0},d=function(){if(this.bubbledKeyCode=this.keyCode,this.ctrlKey)try{this.keyCode=0}catch(a){}this.defaultPrevented=!0,this.returnValue=!1,this.modified=!0};if(b||(b=a.event),!b.target)switch(b.target=b.target||b.srcElement,"mouseover"==b.type&&(b.relatedTarget=b.fromElement),"mouseout"==b.type&&(b.relatedTarget=b.toElement),b.stopPropagation||(b.stopPropagation=c,b.preventDefault=d),b.type){case"keypress":var e="charCode"in b?b.charCode:b.keyCode;10==e?(e=0,b.keyCode=13):13==e||27==e?e=0:3==e&&(e=99),b.charCode=e,b.keyChar=b.charCode?String.fromCharCode(b.charCode):""}return b}function e(a,b,c){if(a.addListener)return a.addListener(b,c),l(function(){a.removeListener(b,c)});if(a.addEventListener)return a.addEventListener(b,c,!1),l(function(){a.removeEventListener(b,c,!1)});if(a.attachEvent){var e=function(a){c(d(a))};return a.attachEvent("on"+b,e),l(function(){a.detachEvent("on"+b,e)})}return a["on"+b]=c,l(function(){a["on"+b]=null})}function f(a,b,c){var d=new m;if("function"==typeof a.item&&"number"==typeof a.length)for(var g=0,h=a.length;h>g;g++)d.add(f(a.item(g),b,c));else a&&d.add(e(a,b,c));return d}var g=c.Observable,h=(g.prototype,g.fromPromise),i=g.throwException,j=c.AnonymousObservable,k=c.AsyncSubject,l=c.Disposable.create,m=c.CompositeDisposable,n=c.Scheduler.immediate,o=Array.prototype.slice;g.start=function(a,b,c){return p(a,b,c)()};var p=g.toAsync=function(a,b,c){return b||(b=timeoutScheduler),function(){var d=arguments,e=new k;return b.schedule(function(){var b;try{b=a.apply(c,d)}catch(f){return void e.onError(f)}e.onNext(b),e.onCompleted()}),e.asObservable()}};g.fromCallback=function(a,b,c,d){return b||(b=n),function(){var e=o.call(arguments,0);return new j(function(f){return b.schedule(function(){function b(a){var b=a;if(d)try{b=d(arguments)}catch(c){return void f.onError(c)}else 1===b.length&&(b=b[0]);f.onNext(b),f.onCompleted()}e.push(b),a.apply(c,e)})})}},g.fromNodeCallback=function(a,b,c,d){return b||(b=n),function(){var e=o.call(arguments,0);return new j(function(f){return b.schedule(function(){function b(a){if(a)return void f.onError(a);var b=o.call(arguments,1);if(d)try{b=d(b)}catch(c){return void f.onError(c)}else 1===b.length&&(b=b[0]);f.onNext(b),f.onCompleted()}e.push(b),a.apply(c,e)})})}};var q=a.angular&&angular.element?angular.element:a.jQuery?a.jQuery:a.Zepto?a.Zepto:null,r=!!a.Ember&&"function"==typeof a.Ember.addListener;g.fromEvent=function(a,b,c){if(r)return s(function(){Ember.addListener(a,b)},function(){Ember.removeListener(a,b)},c);if(q){var d=q(elem);return s(function(a){d.on(b,a)},function(a){d.off(b,a)},c)}return new j(function(d){return f(a,b,function(a){var b=a;if(c)try{b=c(arguments)}catch(e){return void d.onError(e)}d.onNext(b)})}).publish().refCount()};var s=g.fromEventPattern=function(a,b,c){return new j(function(d){function e(a){var b=a;if(c)try{b=c(arguments)}catch(e){return void d.onError(e)}d.onNext(b)}var f=a(e);return l(function(){b&&b(e,f)})}).publish().refCount()};return g.startAsync=function(a){var b;try{b=a()}catch(c){return i(c)}return h(b)},c});
@@ -191,98 +191,122 @@
191
191
  };
192
192
  };
193
193
 
194
- function createListener (element, name, handler) {
195
- // Node.js specific
196
- if (element.addListener) {
197
- element.addListener(name, handler);
198
- return disposableCreate(function () {
199
- element.removeListener(name, handler);
200
- });
201
- } else if (element.addEventListener) {
202
- element.addEventListener(name, handler, false);
203
- return disposableCreate(function () {
204
- element.removeEventListener(name, handler, false);
205
- });
206
- }
194
+ function createListener (element, name, handler) {
195
+ // Node.js specific
196
+ if (element.addListener) {
197
+ element.addListener(name, handler);
198
+ return disposableCreate(function () {
199
+ element.removeListener(name, handler);
200
+ });
201
+ }
202
+ if (element.addEventListener) {
203
+ element.addEventListener(name, handler, false);
204
+ return disposableCreate(function () {
205
+ element.removeEventListener(name, handler, false);
206
+ });
207
207
  }
208
+ throw new Error('No listener found');
209
+ }
208
210
 
209
- function createEventListener (el, eventName, handler) {
210
- var disposables = new CompositeDisposable();
211
+ function createEventListener (el, eventName, handler) {
212
+ var disposables = new CompositeDisposable();
211
213
 
212
- // Asume NodeList
213
- if (el && el.length) {
214
- for (var i = 0, len = el.length; i < len; i++) {
215
- disposables.add(createEventListener(el[i], eventName, handler));
216
- }
217
- } else if (el) {
218
- disposables.add(createListener(el, eventName, handler));
219
- }
220
-
221
- return disposables;
214
+ // Asume NodeList
215
+ if (typeof el.item === 'function' && typeof el.length === 'number') {
216
+ for (var i = 0, len = el.length; i < len; i++) {
217
+ disposables.add(createEventListener(el.item(i), eventName, handler));
218
+ }
219
+ } else if (el) {
220
+ disposables.add(createListener(el, eventName, handler));
222
221
  }
223
222
 
224
- /**
225
- * Creates an observable sequence by adding an event listener to the matching DOMElement or each item in the NodeList.
226
- *
227
- * @example
228
- * var source = Rx.Observable.fromEvent(element, 'mouseup');
229
- *
230
- * @param {Object} element The DOMElement or NodeList to attach a listener.
231
- * @param {String} eventName The event name to attach the observable sequence.
232
- * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
233
- * @returns {Observable} An observable sequence of events from the specified element and the specified event.
234
- */
235
- Observable.fromEvent = function (element, eventName, selector) {
236
- return new AnonymousObservable(function (observer) {
237
- return createEventListener(
238
- element,
239
- eventName,
240
- function handler (e) {
241
- var results = e;
223
+ return disposables;
224
+ }
242
225
 
243
- if (selector) {
244
- try {
245
- results = selector(arguments);
246
- } catch (err) {
247
- observer.onError(err);
248
- return
249
- }
250
- }
226
+ // Check for Angular/jQuery/Zepto support
227
+ var jq =
228
+ !!root.angular && !!angular.element ? angular.element :
229
+ (!!root.jQuery ? root.jQuery : (
230
+ !!root.Zepto ? root.Zepto : null));
251
231
 
252
- observer.onNext(results);
253
- });
254
- }).publish().refCount();
255
- };
256
- /**
257
- * Creates an observable sequence from an event emitter via an addHandler/removeHandler pair.
258
- * @param {Function} addHandler The function to add a handler to the emitter.
259
- * @param {Function} [removeHandler] The optional function to remove a handler from an emitter.
260
- * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
261
- * @returns {Observable} An observable sequence which wraps an event from an event emitter
262
- */
263
- Observable.fromEventPattern = function (addHandler, removeHandler, selector) {
264
- return new AnonymousObservable(function (observer) {
265
- function innerHandler (e) {
266
- var result = e;
267
- if (selector) {
268
- try {
269
- result = selector(arguments);
270
- } catch (err) {
271
- observer.onError(err);
272
- return;
273
- }
274
- }
275
- observer.onNext(result);
232
+ // Check for ember
233
+ var ember = !!root.Ember && typeof root.Ember.addListener === 'function';
234
+
235
+ /**
236
+ * Creates an observable sequence by adding an event listener to the matching DOMElement or each item in the NodeList.
237
+ *
238
+ * @example
239
+ * var source = Rx.Observable.fromEvent(element, 'mouseup');
240
+ *
241
+ * @param {Object} element The DOMElement or NodeList to attach a listener.
242
+ * @param {String} eventName The event name to attach the observable sequence.
243
+ * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
244
+ * @returns {Observable} An observable sequence of events from the specified element and the specified event.
245
+ */
246
+ Observable.fromEvent = function (element, eventName, selector) {
247
+ if (ember) {
248
+ return fromEventPattern(
249
+ function (h) { Ember.addListener(element, eventName); },
250
+ function (h) { Ember.removeListener(element, eventName); },
251
+ selector);
252
+ }
253
+ if (jq) {
254
+ var $elem = jq(elem);
255
+ return fromEventPattern(
256
+ function (h) { $elem.on(eventName, h); },
257
+ function (h) { $elem.off(eventName, h); },
258
+ selector);
259
+ }
260
+ return new AnonymousObservable(function (observer) {
261
+ return createEventListener(
262
+ element,
263
+ eventName,
264
+ function handler (e) {
265
+ var results = e;
266
+
267
+ if (selector) {
268
+ try {
269
+ results = selector(arguments);
270
+ } catch (err) {
271
+ observer.onError(err);
272
+ return
276
273
  }
274
+ }
277
275
 
278
- var returnValue = addHandler(innerHandler);
279
- return disposableCreate(function () {
280
- if (removeHandler) {
281
- removeHandler(innerHandler, returnValue);
282
- }
283
- });
284
- }).publish().refCount();
285
- };
276
+ observer.onNext(results);
277
+ });
278
+ }).publish().refCount();
279
+ };
280
+ /**
281
+ * Creates an observable sequence from an event emitter via an addHandler/removeHandler pair.
282
+ * @param {Function} addHandler The function to add a handler to the emitter.
283
+ * @param {Function} [removeHandler] The optional function to remove a handler from an emitter.
284
+ * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.
285
+ * @returns {Observable} An observable sequence which wraps an event from an event emitter
286
+ */
287
+ var fromEventPattern = Observable.fromEventPattern = function (addHandler, removeHandler, selector) {
288
+ return new AnonymousObservable(function (observer) {
289
+ function innerHandler (e) {
290
+ var result = e;
291
+ if (selector) {
292
+ try {
293
+ result = selector(arguments);
294
+ } catch (err) {
295
+ observer.onError(err);
296
+ return;
297
+ }
298
+ }
299
+ observer.onNext(result);
300
+ }
301
+
302
+ var returnValue = addHandler(innerHandler);
303
+ return disposableCreate(function () {
304
+ if (removeHandler) {
305
+ removeHandler(innerHandler, returnValue);
306
+ }
307
+ });
308
+ }).publish().refCount();
309
+ };
286
310
 
287
311
  /**
288
312
  * Invokes the asynchronous function, surfacing the result through an observable sequence.