rxjs-rails 2.3.11 → 2.3.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -47,36 +47,17 @@
47
47
  isScheduler = Rx.helpers.isScheduler,
48
48
  slice = Array.prototype.slice;
49
49
 
50
- var fnString = 'function';
50
+ var fnString = 'function',
51
+ throwString = 'throw';
51
52
 
52
53
  function toThunk(obj, ctx) {
53
- if (Array.isArray(obj)) {
54
- return objectToThunk.call(ctx, obj);
55
- }
56
-
57
- if (isGeneratorFunction(obj)) {
58
- return observableSpawn(obj.call(ctx));
59
- }
60
-
61
- if (isGenerator(obj)) {
62
- return observableSpawn(obj);
63
- }
64
-
65
- if (isObservable(obj)) {
66
- return observableToThunk(obj);
67
- }
68
-
69
- if (isPromise(obj)) {
70
- return promiseToThunk(obj);
71
- }
72
-
73
- if (typeof obj === fnString) {
74
- return obj;
75
- }
76
-
77
- if (isObject(obj) || Array.isArray(obj)) {
78
- return objectToThunk.call(ctx, obj);
79
- }
54
+ if (Array.isArray(obj)) { return objectToThunk.call(ctx, obj); }
55
+ if (isGeneratorFunction(obj)) { return observableSpawn(obj.call(ctx)); }
56
+ if (isGenerator(obj)) { return observableSpawn(obj); }
57
+ if (isObservable(obj)) { return observableToThunk(obj); }
58
+ if (isPromise(obj)) { return promiseToThunk(obj); }
59
+ if (typeof obj === fnString) { return obj; }
60
+ if (isObject(obj) || Array.isArray(obj)) { return objectToThunk.call(ctx, obj); }
80
61
 
81
62
  return obj;
82
63
  }
@@ -128,7 +109,7 @@
128
109
  }
129
110
  }
130
111
 
131
- function observableToThink(observable) {
112
+ function observableToThunk(observable) {
132
113
  return function (fn) {
133
114
  var value, hasValue = false;
134
115
  observable.subscribe(
@@ -152,7 +133,7 @@
152
133
  }
153
134
 
154
135
  function isObservable(obj) {
155
- return obj && obj.prototype.subscribe === fnString;
136
+ return obj && typeof obj.subscribe === fnString;
156
137
  }
157
138
 
158
139
  function isGeneratorFunction(obj) {
@@ -160,7 +141,7 @@
160
141
  }
161
142
 
162
143
  function isGenerator(obj) {
163
- return obj && typeof obj.next === fnString && typeof obj.throw === fnString;
144
+ return obj && typeof obj.next === fnString && typeof obj[throwString] === fnString;
164
145
  }
165
146
 
166
147
  function isObject(val) {
@@ -177,7 +158,7 @@
177
158
 
178
159
  return function (done) {
179
160
  var ctx = this,
180
- gen = fan;
161
+ gen = fn;
181
162
 
182
163
  if (isGenFun) {
183
164
  var args = slice.call(arguments),
@@ -204,7 +185,7 @@
204
185
 
205
186
  if (err) {
206
187
  try {
207
- ret = gen.throw(err);
188
+ ret = gen[throwString](err);
208
189
  } catch (e) {
209
190
  return exit(e);
210
191
  }
@@ -288,6 +269,13 @@
288
269
  }
289
270
  };
290
271
 
272
+ function error(err) {
273
+ if (!err) { return; }
274
+ timeoutScheduler.schedule(function(){
275
+ throw err;
276
+ });
277
+ }
278
+
291
279
  /**
292
280
  * Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence.
293
281
  *
@@ -1,3 +1,3 @@
1
1
  /* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/
2
- (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,b){return Array.isArray(a)?e.call(b,a):h(a)?x(a.call(b)):i(a)?x(a):g(a)?observableToThunk(a):isPromise(a)?f(a):typeof a===w?a:j(a)||Array.isArray(a)?e.call(b,a):a}function e(a){var b=this;return function(c){function e(a,e){if(!f)try{if(a=d(a,b),typeof a!==w)return i[e]=a,--h||c(null,i);a.call(b,function(a,b){if(!f){if(a)return f=!0,c(a);i[e]=b,--h||c(null,i)}})}catch(g){f=!0,c(g)}}var f,g=Object.keys(a),h=g.length,i=new a.constructor;if(!h)return void t.schedule(function(){c(null,i)});for(var j=0,k=g.length;k>j;j++)e(a[g[j]],g[j])}}function f(a){return function(b){a.then(function(a){b(null,a)},b)}}function g(a){return a&&a.prototype.subscribe===w}function h(a){return a&&a.constructor&&"GeneratorFunction"===a.constructor.name}function i(a){return a&&typeof a.next===w&&typeof a.throw===w}function j(a){return a&&a.constructor===Object}function k(a,b,c){if(a.addEventListener)return a.addEventListener(b,c,!1),r(function(){a.removeEventListener(b,c,!1)});throw new Error("No listener found")}function l(a,b,c){var d=new s;if("[object NodeList]"===Object.prototype.toString.call(a))for(var e=0,f=a.length;f>e;e++)d.add(l(a.item(e),b,c));else a&&d.add(k(a,b,c));return d}var m=c.Observable,n=(m.prototype,m.fromPromise),o=m.throwException,p=c.AnonymousObservable,q=c.AsyncSubject,r=c.Disposable.create,s=c.CompositeDisposable,t=(c.Scheduler.immediate,c.Scheduler.timeout),u=c.helpers.isScheduler,v=Array.prototype.slice,w="function",x=c.spawn=function(a){var b=h(a);return function(c){function e(a,b){t.schedule(c.bind(g,a,b))}function f(a,b){var c;if(arguments.length>2&&(b=v.call(arguments,1)),a)try{c=h.throw(a)}catch(i){return e(i)}if(!a)try{c=h.next(b)}catch(i){return e(i)}if(c.done)return e(null,c.value);if(c.value=d(c.value,g),typeof c.value!==w)f(new TypeError("Rx.spawn only supports a function, Promise, Observable, Object or Array."));else{var j=!1;try{c.value.call(g,function(){j||(j=!0,f.apply(g,arguments))})}catch(i){t.schedule(function(){j||(j=!0,f.call(g,i))})}}}var g=this,h=fan;if(b){var i=v.call(arguments),j=i.length,k=j&&typeof i[j-1]===w;c=k?i.pop():error,h=a.apply(this,i)}else c=c||error;f()}};c.denodify=function(a){return function(){var b,c,d,e=v.call(arguments);return e.push(function(){b=arguments,d&&!c&&(c=!0,cb.apply(this,b))}),a.apply(this,e),function(a){d=a,b&&!c&&(c=!0,a.apply(this,b))}}},m.start=function(a,b,c){return y(a,b,c)()};var y=m.toAsync=function(a,b,c){return u(c)||(c=t),function(){var d=arguments,e=new q;return c.schedule(function(){var c;try{c=a.apply(b,d)}catch(f){return void e.onError(f)}e.onNext(c),e.onCompleted()}),e.asObservable()}};m.fromCallback=function(a,b,c){return function(){var d=v.call(arguments,0);return new p(function(e){function f(a){var b=a;if(c){try{b=c(arguments)}catch(d){return void e.onError(d)}e.onNext(b)}else b.length<=1?e.onNext.apply(e,b):e.onNext(b);e.onCompleted()}d.push(f),a.apply(b,d)}).publishLast().refCount()}},m.fromNodeCallback=function(a,b,c){return function(){var d=v.call(arguments,0);return new p(function(e){function f(a){if(a)return void e.onError(a);var b=v.call(arguments,1);if(c){try{b=c(b)}catch(d){return void e.onError(d)}e.onNext(b)}else b.length<=1?e.onNext.apply(e,b):e.onNext(b);e.onCompleted()}d.push(f),a.apply(b,d)}).publishLast().refCount()}},c.config.useNativeEvents=!1;var z=a.angular&&angular.element?angular.element:a.jQuery?a.jQuery:a.Zepto?a.Zepto:null,A=!!a.Ember&&"function"==typeof a.Ember.addListener,B=!!a.Backbone&&!!a.Backbone.Marionette;m.fromEvent=function(a,b,d){if(a.addListener)return C(function(c){a.addListener(b,c)},function(c){a.removeListener(b,c)},d);if(!c.config.useNativeEvents){if(B)return C(function(c){a.on(b,c)},function(c){a.off(b,c)},d);if(A)return C(function(c){Ember.addListener(a,b,c)},function(c){Ember.removeListener(a,b,c)},d);if(z){var e=z(a);return C(function(a){e.on(b,a)},function(a){e.off(b,a)},d)}}return new p(function(c){return l(a,b,function(a){var b=a;if(d)try{b=d(arguments)}catch(e){return void c.onError(e)}c.onNext(b)})}).publish().refCount()};var C=m.fromEventPattern=function(a,b,c){return new p(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 r(function(){b&&b(e,f)})}).publish().refCount()};return m.startAsync=function(a){var b;try{b=a()}catch(c){return o(c)}return n(b)},c});
2
+ (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,b){return Array.isArray(a)?e.call(b,a):i(a)?A(a.call(b)):j(a)?A(a):h(a)?f(a):isPromise(a)?g(a):typeof a===y?a:k(a)||Array.isArray(a)?e.call(b,a):a}function e(a){var b=this;return function(c){function e(a,e){if(!f)try{if(a=d(a,b),typeof a!==y)return i[e]=a,--h||c(null,i);a.call(b,function(a,b){if(!f){if(a)return f=!0,c(a);i[e]=b,--h||c(null,i)}})}catch(g){f=!0,c(g)}}var f,g=Object.keys(a),h=g.length,i=new a.constructor;if(!h)return void v.schedule(function(){c(null,i)});for(var j=0,k=g.length;k>j;j++)e(a[g[j]],g[j])}}function f(a){return function(b){var c,d=!1;a.subscribe(function(a){c=a,d=!0},b,function(){d&&b(null,c)})}}function g(a){return function(b){a.then(function(a){b(null,a)},b)}}function h(a){return a&&typeof a.subscribe===y}function i(a){return a&&a.constructor&&"GeneratorFunction"===a.constructor.name}function j(a){return a&&typeof a.next===y&&typeof a[z]===y}function k(a){return a&&a.constructor===Object}function l(a){a&&v.schedule(function(){throw a})}function m(a,b,c){if(a.addEventListener)return a.addEventListener(b,c,!1),t(function(){a.removeEventListener(b,c,!1)});throw new Error("No listener found")}function n(a,b,c){var d=new u;if("[object NodeList]"===Object.prototype.toString.call(a))for(var e=0,f=a.length;f>e;e++)d.add(n(a.item(e),b,c));else a&&d.add(m(a,b,c));return d}var o=c.Observable,p=(o.prototype,o.fromPromise),q=o.throwException,r=c.AnonymousObservable,s=c.AsyncSubject,t=c.Disposable.create,u=c.CompositeDisposable,v=(c.Scheduler.immediate,c.Scheduler.timeout),w=c.helpers.isScheduler,x=Array.prototype.slice,y="function",z="throw",A=c.spawn=function(a){var b=i(a);return function(c){function e(a,b){v.schedule(c.bind(g,a,b))}function f(a,b){var c;if(arguments.length>2&&(b=x.call(arguments,1)),a)try{c=h[z](a)}catch(i){return e(i)}if(!a)try{c=h.next(b)}catch(i){return e(i)}if(c.done)return e(null,c.value);if(c.value=d(c.value,g),typeof c.value!==y)f(new TypeError("Rx.spawn only supports a function, Promise, Observable, Object or Array."));else{var j=!1;try{c.value.call(g,function(){j||(j=!0,f.apply(g,arguments))})}catch(i){v.schedule(function(){j||(j=!0,f.call(g,i))})}}}var g=this,h=a;if(b){var i=x.call(arguments),j=i.length,k=j&&typeof i[j-1]===y;c=k?i.pop():l,h=a.apply(this,i)}else c=c||l;f()}};c.denodify=function(a){return function(){var b,c,d,e=x.call(arguments);return e.push(function(){b=arguments,d&&!c&&(c=!0,cb.apply(this,b))}),a.apply(this,e),function(a){d=a,b&&!c&&(c=!0,a.apply(this,b))}}},o.start=function(a,b,c){return B(a,b,c)()};var B=o.toAsync=function(a,b,c){return w(c)||(c=v),function(){var d=arguments,e=new s;return c.schedule(function(){var c;try{c=a.apply(b,d)}catch(f){return void e.onError(f)}e.onNext(c),e.onCompleted()}),e.asObservable()}};o.fromCallback=function(a,b,c){return function(){var d=x.call(arguments,0);return new r(function(e){function f(a){var b=a;if(c){try{b=c(arguments)}catch(d){return void e.onError(d)}e.onNext(b)}else b.length<=1?e.onNext.apply(e,b):e.onNext(b);e.onCompleted()}d.push(f),a.apply(b,d)}).publishLast().refCount()}},o.fromNodeCallback=function(a,b,c){return function(){var d=x.call(arguments,0);return new r(function(e){function f(a){if(a)return void e.onError(a);var b=x.call(arguments,1);if(c){try{b=c(b)}catch(d){return void e.onError(d)}e.onNext(b)}else b.length<=1?e.onNext.apply(e,b):e.onNext(b);e.onCompleted()}d.push(f),a.apply(b,d)}).publishLast().refCount()}},c.config.useNativeEvents=!1;var C=a.angular&&angular.element?angular.element:a.jQuery?a.jQuery:a.Zepto?a.Zepto:null,D=!!a.Ember&&"function"==typeof a.Ember.addListener,E=!!a.Backbone&&!!a.Backbone.Marionette;o.fromEvent=function(a,b,d){if(a.addListener)return F(function(c){a.addListener(b,c)},function(c){a.removeListener(b,c)},d);if(!c.config.useNativeEvents){if(E)return F(function(c){a.on(b,c)},function(c){a.off(b,c)},d);if(D)return F(function(c){Ember.addListener(a,b,c)},function(c){Ember.removeListener(a,b,c)},d);if(C){var e=C(a);return F(function(a){e.on(b,a)},function(a){e.off(b,a)},d)}}return new r(function(c){return n(a,b,function(a){var b=a;if(d)try{b=d(arguments)}catch(e){return void c.onError(e)}c.onNext(b)})}).publish().refCount()};var F=o.fromEventPattern=function(a,b,c){return new r(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 t(function(){b&&b(e,f)})}).publish().refCount()};return o.startAsync=function(a){var b;try{b=a()}catch(c){return q(c)}return p(b)},c});
3
3
  //# sourceMappingURL=rx.async.map