rxjs-rails 0.0.1 → 2.2.13
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +38 -1
- data/lib/rxjs/rails/version.rb +1 -2
- data/vendor/assets/javascripts/rx.async.compat.js +87 -66
- data/vendor/assets/javascripts/rx.async.compat.min.js +1 -1
- data/vendor/assets/javascripts/rx.async.js +87 -66
- data/vendor/assets/javascripts/rx.async.min.js +1 -1
- data/vendor/assets/javascripts/rx.binding.js +1 -1
- data/vendor/assets/javascripts/rx.binding.min.js +1 -1
- data/vendor/assets/javascripts/rx.compat.js +86 -62
- data/vendor/assets/javascripts/rx.compat.min.js +2 -2
- data/vendor/assets/javascripts/rx.lite.compat.js +171 -126
- data/vendor/assets/javascripts/rx.lite.compat.min.js +2 -2
- data/vendor/assets/javascripts/rx.lite.js +165 -120
- data/vendor/assets/javascripts/rx.lite.min.js +2 -2
- data/vendor/assets/javascripts/rx.min.js +2 -2
- data/vendor/assets/javascripts/rx.node.js +1 -1
- data/vendor/assets/javascripts/rx.testing.js +5 -3
- data/vendor/assets/javascripts/rx.testing.min.js +1 -1
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cd9cfa7ff886d2879628f84d0ee022db47f2313
|
4
|
+
data.tar.gz: 3b02e3507e069380447e0e52e3e6db6043c274cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9afd1e426823cbb75251925ce7939cac33ba72437ed048185f21351fb9c1c50a73ae05e04f6df03de349073895f6acb62bdb5065e353d95d6ff6c05747003a1f
|
7
|
+
data.tar.gz: 51c444ba1fba49125874a50b7989fb32da4328ae65100dc8ba7b33ee24b5649cec41a3a127067420ef1a9d78ed7b80ed83dc0141ab4a1b5b80adfc4cc4359a74
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Adds the excellent Reactive Extensions library to rails.
|
|
4
4
|
|
5
5
|
See the [RxJS website](http://reactive-extensions.github.io/RxJS/) for more info.
|
6
6
|
|
7
|
-
|
7
|
+
## Installation
|
8
8
|
|
9
9
|
Add `gem 'rxjs-rails'` to your Gemfile
|
10
10
|
|
@@ -12,3 +12,40 @@ Reference the appropriate rx.js file in your application.js eg:
|
|
12
12
|
|
13
13
|
`*= require rx.lite`
|
14
14
|
|
15
|
+
Available js files:
|
16
|
+
|
17
|
+
rx.aggregates.js
|
18
|
+
rx.aggregates.min.js
|
19
|
+
rx.async.compat.js
|
20
|
+
rx.async.compat.min.js
|
21
|
+
rx.async.js
|
22
|
+
rx.async.min.js
|
23
|
+
rx.binding.js
|
24
|
+
rx.binding.min.js
|
25
|
+
rx.coincidence.js
|
26
|
+
rx.coincidence.min.js
|
27
|
+
rx.compat.js
|
28
|
+
rx.compat.min.js
|
29
|
+
rx.experimental.js
|
30
|
+
rx.experimental.min.js
|
31
|
+
rx.joinpatterns.js
|
32
|
+
rx.joinpatterns.min.js
|
33
|
+
rx.lite.compat.js
|
34
|
+
rx.lite.compat.min.js
|
35
|
+
rx.lite.js
|
36
|
+
rx.lite.min.js
|
37
|
+
rx.min.js
|
38
|
+
rx.node.js
|
39
|
+
rx.testing.js
|
40
|
+
rx.testing.min.js
|
41
|
+
rx.time.js
|
42
|
+
rx.time.min.js
|
43
|
+
rx.virtualtime.js
|
44
|
+
rx.virtualtime.min.js
|
45
|
+
|
46
|
+
## versions
|
47
|
+
|
48
|
+
```
|
49
|
+
Version now mirrors RxJS release
|
50
|
+
```
|
51
|
+
|
data/lib/rxjs/rails/version.rb
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
// Because of build optimizers
|
24
24
|
if (typeof define === 'function' && define.amd) {
|
25
|
-
define(['rx', 'exports'], function (Rx, exports) {
|
25
|
+
define(['rx.binding', 'exports'], function (Rx, exports) {
|
26
26
|
root.Rx = factory(root, exports, Rx);
|
27
27
|
return root.Rx;
|
28
28
|
});
|
@@ -35,12 +35,12 @@
|
|
35
35
|
|
36
36
|
// Aliases
|
37
37
|
var Observable = Rx.Observable,
|
38
|
+
observableProto = Observable.prototype,
|
38
39
|
AnonymousObservable = Rx.Internals.AnonymousObservable,
|
39
40
|
AsyncSubject = Rx.AsyncSubject,
|
40
41
|
disposableCreate = Rx.Disposable.create,
|
41
42
|
CompositeDisposable= Rx.CompositeDisposable,
|
42
|
-
|
43
|
-
timeoutScheduler = Rx.Scheduler.timeout,
|
43
|
+
immediateScheduler = Rx.Scheduler.immediate,
|
44
44
|
slice = Array.prototype.slice;
|
45
45
|
|
46
46
|
/**
|
@@ -108,37 +108,36 @@
|
|
108
108
|
* @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array.
|
109
109
|
*/
|
110
110
|
Observable.fromCallback = function (func, scheduler, context, selector) {
|
111
|
-
scheduler || (scheduler =
|
111
|
+
scheduler || (scheduler = immediateScheduler);
|
112
112
|
return function () {
|
113
|
-
var args = slice.call(arguments, 0)
|
114
|
-
subject = new AsyncSubject();
|
113
|
+
var args = slice.call(arguments, 0);
|
115
114
|
|
116
|
-
|
117
|
-
function
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
results
|
115
|
+
return new AnonymousObservable(function (observer) {
|
116
|
+
return scheduler.schedule(function () {
|
117
|
+
function handler(e) {
|
118
|
+
var results = e;
|
119
|
+
|
120
|
+
if (selector) {
|
121
|
+
try {
|
122
|
+
results = selector(arguments);
|
123
|
+
} catch (err) {
|
124
|
+
observer.onError(err);
|
125
|
+
return;
|
126
|
+
}
|
127
|
+
} else {
|
128
|
+
if (results.length === 1) {
|
129
|
+
results = results[0];
|
130
|
+
}
|
130
131
|
}
|
131
|
-
}
|
132
132
|
|
133
|
-
|
134
|
-
|
135
|
-
|
133
|
+
observer.onNext(results);
|
134
|
+
observer.onCompleted();
|
135
|
+
}
|
136
136
|
|
137
|
-
|
138
|
-
|
137
|
+
args.push(handler);
|
138
|
+
func.apply(context, args);
|
139
|
+
});
|
139
140
|
});
|
140
|
-
|
141
|
-
return subject.asObservable();
|
142
141
|
};
|
143
142
|
};
|
144
143
|
|
@@ -151,42 +150,42 @@
|
|
151
150
|
* @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.
|
152
151
|
*/
|
153
152
|
Observable.fromNodeCallback = function (func, scheduler, context, selector) {
|
154
|
-
scheduler || (scheduler =
|
153
|
+
scheduler || (scheduler = immediateScheduler);
|
155
154
|
return function () {
|
156
|
-
var args = slice.call(arguments, 0)
|
157
|
-
subject = new AsyncSubject();
|
158
|
-
|
159
|
-
scheduler.schedule(function () {
|
160
|
-
function handler(err) {
|
161
|
-
if (err) {
|
162
|
-
subject.onError(err);
|
163
|
-
return;
|
164
|
-
}
|
155
|
+
var args = slice.call(arguments, 0);
|
165
156
|
|
166
|
-
|
157
|
+
return new AnonymousObservable(function (observer) {
|
158
|
+
return scheduler.schedule(function () {
|
167
159
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
} catch (e) {
|
172
|
-
subject.onError(e);
|
160
|
+
function handler(err) {
|
161
|
+
if (err) {
|
162
|
+
observer.onError(err);
|
173
163
|
return;
|
174
164
|
}
|
175
|
-
|
176
|
-
|
177
|
-
|
165
|
+
|
166
|
+
var results = slice.call(arguments, 1);
|
167
|
+
|
168
|
+
if (selector) {
|
169
|
+
try {
|
170
|
+
results = selector(results);
|
171
|
+
} catch (e) {
|
172
|
+
observer.onError(e);
|
173
|
+
return;
|
174
|
+
}
|
175
|
+
} else {
|
176
|
+
if (results.length === 1) {
|
177
|
+
results = results[0];
|
178
|
+
}
|
178
179
|
}
|
179
|
-
}
|
180
180
|
|
181
|
-
|
182
|
-
|
183
|
-
|
181
|
+
observer.onNext(results);
|
182
|
+
observer.onCompleted();
|
183
|
+
}
|
184
184
|
|
185
|
-
|
186
|
-
|
185
|
+
args.push(handler);
|
186
|
+
func.apply(context, args);
|
187
|
+
});
|
187
188
|
});
|
188
|
-
|
189
|
-
return subject.asObservable();
|
190
189
|
};
|
191
190
|
};
|
192
191
|
|
@@ -359,18 +358,40 @@
|
|
359
358
|
* @returns {Observable} An Observable sequence which wraps the existing promise success and failure.
|
360
359
|
*/
|
361
360
|
Observable.fromPromise = function (promise) {
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
361
|
+
return new AnonymousObservable(function (observer) {
|
362
|
+
promise.then(
|
363
|
+
function (value) {
|
364
|
+
observer.onNext(value);
|
365
|
+
observer.onCompleted();
|
366
|
+
},
|
367
|
+
function (reason) {
|
368
|
+
observer.onError(reason);
|
369
|
+
});
|
370
|
+
});
|
371
|
+
};
|
372
|
+
/*
|
373
|
+
* Converts an existing observable sequence to an ES6 Compatible Promise
|
374
|
+
* @example
|
375
|
+
* var promise = Rx.Observable.return(42).toPromise(RSVP.Promise);
|
376
|
+
* @param {Function} The constructor of the promise
|
377
|
+
* @returns {Promise} An ES6 compatible promise with the last value from the observable sequence.
|
378
|
+
*/
|
379
|
+
observableProto.toPromise = function (promiseCtor) {
|
380
|
+
var source = this;
|
381
|
+
return new promiseCtor(function (resolve, reject) {
|
382
|
+
// No cancellation can be done
|
383
|
+
var value, hasValue = false;
|
384
|
+
source.subscribe(function (v) {
|
385
|
+
value = v;
|
386
|
+
hasValue = true;
|
387
|
+
}, function (err) {
|
388
|
+
reject(err);
|
389
|
+
}, function () {
|
390
|
+
if (hasValue) {
|
391
|
+
resolve(value);
|
392
|
+
}
|
371
393
|
});
|
372
|
-
|
373
|
-
return subject.asObservable();
|
394
|
+
});
|
374
395
|
};
|
375
396
|
return Rx;
|
376
397
|
}));
|
@@ -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){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),
|
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),k(function(){a.removeListener(b,c)});if(a.addEventListener)return a.addEventListener(b,c,!1),k(function(){a.removeEventListener(b,c,!1)});if(a.attachEvent){var e=function(a){c(d(a))};return a.attachEvent("on"+b,e),k(function(){a.detachEvent("on"+b,e)})}return a["on"+b]=c,k(function(){a["on"+b]=null})}function f(a,b,c){var d=new l;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,i=c.Internals.AnonymousObservable,j=c.AsyncSubject,k=c.Disposable.create,l=c.CompositeDisposable,m=c.Scheduler.immediate,n=Array.prototype.slice;g.start=function(a,b,c){return o(a,b,c)()};var o=g.toAsync=function(a,b,c){return b||(b=timeoutScheduler),function(){var d=arguments,e=new j;return b.schedule(function(){var b;try{b=a.apply(c,d)}catch(f){return e.onError(f),void 0}e.onNext(b),e.onCompleted()}),e.asObservable()}};return g.fromCallback=function(a,b,c,d){return b||(b=m),function(){var e=n.call(arguments,0);return new i(function(f){return b.schedule(function(){function b(a){var b=a;if(d)try{b=d(arguments)}catch(c){return f.onError(c),void 0}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=m),function(){var e=n.call(arguments,0);return new i(function(f){return b.schedule(function(){function b(a){if(a)return f.onError(a),void 0;var b=n.call(arguments,1);if(d)try{b=d(b)}catch(c){return f.onError(c),void 0}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 i(function(d){return f(a,b,function(a){var b=a;if(c)try{b=c(arguments)}catch(e){return d.onError(e),void 0}d.onNext(b)})}).publish().refCount()},g.fromEventPattern=function(a,b,c){return new i(function(d){function e(a){var b=a;if(c)try{b=c(arguments)}catch(e){return d.onError(e),void 0}d.onNext(b)}var f=a(e);return k(function(){b&&b(e,f)})}).publish().refCount()},g.fromPromise=function(a){return new i(function(b){a.then(function(a){b.onNext(a),b.onCompleted()},function(a){b.onError(a)})})},h.toPromise=function(a){var b=this;return new a(function(a,c){var d,e=!1;b.subscribe(function(a){d=a,e=!0},function(a){c(a)},function(){e&&a(d)})})},c});
|
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
// Because of build optimizers
|
24
24
|
if (typeof define === 'function' && define.amd) {
|
25
|
-
define(['rx', 'exports'], function (Rx, exports) {
|
25
|
+
define(['rx.binding', 'exports'], function (Rx, exports) {
|
26
26
|
root.Rx = factory(root, exports, Rx);
|
27
27
|
return root.Rx;
|
28
28
|
});
|
@@ -35,12 +35,12 @@
|
|
35
35
|
|
36
36
|
// Aliases
|
37
37
|
var Observable = Rx.Observable,
|
38
|
+
observableProto = Observable.prototype,
|
38
39
|
AnonymousObservable = Rx.Internals.AnonymousObservable,
|
39
40
|
AsyncSubject = Rx.AsyncSubject,
|
40
41
|
disposableCreate = Rx.Disposable.create,
|
41
42
|
CompositeDisposable= Rx.CompositeDisposable,
|
42
|
-
|
43
|
-
timeoutScheduler = Rx.Scheduler.timeout,
|
43
|
+
immediateScheduler = Rx.Scheduler.immediate,
|
44
44
|
slice = Array.prototype.slice;
|
45
45
|
|
46
46
|
/**
|
@@ -108,37 +108,36 @@
|
|
108
108
|
* @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array.
|
109
109
|
*/
|
110
110
|
Observable.fromCallback = function (func, scheduler, context, selector) {
|
111
|
-
scheduler || (scheduler =
|
111
|
+
scheduler || (scheduler = immediateScheduler);
|
112
112
|
return function () {
|
113
|
-
var args = slice.call(arguments, 0)
|
114
|
-
subject = new AsyncSubject();
|
113
|
+
var args = slice.call(arguments, 0);
|
115
114
|
|
116
|
-
|
117
|
-
function
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
results
|
115
|
+
return new AnonymousObservable(function (observer) {
|
116
|
+
return scheduler.schedule(function () {
|
117
|
+
function handler(e) {
|
118
|
+
var results = e;
|
119
|
+
|
120
|
+
if (selector) {
|
121
|
+
try {
|
122
|
+
results = selector(arguments);
|
123
|
+
} catch (err) {
|
124
|
+
observer.onError(err);
|
125
|
+
return;
|
126
|
+
}
|
127
|
+
} else {
|
128
|
+
if (results.length === 1) {
|
129
|
+
results = results[0];
|
130
|
+
}
|
130
131
|
}
|
131
|
-
}
|
132
132
|
|
133
|
-
|
134
|
-
|
135
|
-
|
133
|
+
observer.onNext(results);
|
134
|
+
observer.onCompleted();
|
135
|
+
}
|
136
136
|
|
137
|
-
|
138
|
-
|
137
|
+
args.push(handler);
|
138
|
+
func.apply(context, args);
|
139
|
+
});
|
139
140
|
});
|
140
|
-
|
141
|
-
return subject.asObservable();
|
142
141
|
};
|
143
142
|
};
|
144
143
|
|
@@ -151,42 +150,42 @@
|
|
151
150
|
* @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.
|
152
151
|
*/
|
153
152
|
Observable.fromNodeCallback = function (func, scheduler, context, selector) {
|
154
|
-
scheduler || (scheduler =
|
153
|
+
scheduler || (scheduler = immediateScheduler);
|
155
154
|
return function () {
|
156
|
-
var args = slice.call(arguments, 0)
|
157
|
-
subject = new AsyncSubject();
|
158
|
-
|
159
|
-
scheduler.schedule(function () {
|
160
|
-
function handler(err) {
|
161
|
-
if (err) {
|
162
|
-
subject.onError(err);
|
163
|
-
return;
|
164
|
-
}
|
155
|
+
var args = slice.call(arguments, 0);
|
165
156
|
|
166
|
-
|
157
|
+
return new AnonymousObservable(function (observer) {
|
158
|
+
return scheduler.schedule(function () {
|
167
159
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
} catch (e) {
|
172
|
-
subject.onError(e);
|
160
|
+
function handler(err) {
|
161
|
+
if (err) {
|
162
|
+
observer.onError(err);
|
173
163
|
return;
|
174
164
|
}
|
175
|
-
|
176
|
-
|
177
|
-
|
165
|
+
|
166
|
+
var results = slice.call(arguments, 1);
|
167
|
+
|
168
|
+
if (selector) {
|
169
|
+
try {
|
170
|
+
results = selector(results);
|
171
|
+
} catch (e) {
|
172
|
+
observer.onError(e);
|
173
|
+
return;
|
174
|
+
}
|
175
|
+
} else {
|
176
|
+
if (results.length === 1) {
|
177
|
+
results = results[0];
|
178
|
+
}
|
178
179
|
}
|
179
|
-
}
|
180
180
|
|
181
|
-
|
182
|
-
|
183
|
-
|
181
|
+
observer.onNext(results);
|
182
|
+
observer.onCompleted();
|
183
|
+
}
|
184
184
|
|
185
|
-
|
186
|
-
|
185
|
+
args.push(handler);
|
186
|
+
func.apply(context, args);
|
187
|
+
});
|
187
188
|
});
|
188
|
-
|
189
|
-
return subject.asObservable();
|
190
189
|
};
|
191
190
|
};
|
192
191
|
|
@@ -289,18 +288,40 @@
|
|
289
288
|
* @returns {Observable} An Observable sequence which wraps the existing promise success and failure.
|
290
289
|
*/
|
291
290
|
Observable.fromPromise = function (promise) {
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
291
|
+
return new AnonymousObservable(function (observer) {
|
292
|
+
promise.then(
|
293
|
+
function (value) {
|
294
|
+
observer.onNext(value);
|
295
|
+
observer.onCompleted();
|
296
|
+
},
|
297
|
+
function (reason) {
|
298
|
+
observer.onError(reason);
|
299
|
+
});
|
300
|
+
});
|
301
|
+
};
|
302
|
+
/*
|
303
|
+
* Converts an existing observable sequence to an ES6 Compatible Promise
|
304
|
+
* @example
|
305
|
+
* var promise = Rx.Observable.return(42).toPromise(RSVP.Promise);
|
306
|
+
* @param {Function} The constructor of the promise
|
307
|
+
* @returns {Promise} An ES6 compatible promise with the last value from the observable sequence.
|
308
|
+
*/
|
309
|
+
observableProto.toPromise = function (promiseCtor) {
|
310
|
+
var source = this;
|
311
|
+
return new promiseCtor(function (resolve, reject) {
|
312
|
+
// No cancellation can be done
|
313
|
+
var value, hasValue = false;
|
314
|
+
source.subscribe(function (v) {
|
315
|
+
value = v;
|
316
|
+
hasValue = true;
|
317
|
+
}, function (err) {
|
318
|
+
reject(err);
|
319
|
+
}, function () {
|
320
|
+
if (hasValue) {
|
321
|
+
resolve(value);
|
322
|
+
}
|
301
323
|
});
|
302
|
-
|
303
|
-
return subject.asObservable();
|
324
|
+
});
|
304
325
|
};
|
305
326
|
return Rx;
|
306
327
|
}));
|
@@ -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){function d(a,b,c){return a.addListener?(a.addListener(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(a,b,c){return a.addListener?(a.addListener(b,c),j(function(){a.removeListener(b,c)})):a.addEventListener?(a.addEventListener(b,c,!1),j(function(){a.removeEventListener(b,c,!1)})):void 0}function e(a,b,c){var f=new k;if(a&&a.length)for(var g=0,h=a.length;h>g;g++)f.add(e(a[g],b,c));else a&&f.add(d(a,b,c));return f}var f=c.Observable,g=f.prototype,h=c.Internals.AnonymousObservable,i=c.AsyncSubject,j=c.Disposable.create,k=c.CompositeDisposable,l=c.Scheduler.immediate,m=Array.prototype.slice;f.start=function(a,b,c){return n(a,b,c)()};var n=f.toAsync=function(a,b,c){return b||(b=timeoutScheduler),function(){var d=arguments,e=new i;return b.schedule(function(){var b;try{b=a.apply(c,d)}catch(f){return e.onError(f),void 0}e.onNext(b),e.onCompleted()}),e.asObservable()}};return f.fromCallback=function(a,b,c,d){return b||(b=l),function(){var e=m.call(arguments,0);return new h(function(f){return b.schedule(function(){function b(a){var b=a;if(d)try{b=d(arguments)}catch(c){return f.onError(c),void 0}else 1===b.length&&(b=b[0]);f.onNext(b),f.onCompleted()}e.push(b),a.apply(c,e)})})}},f.fromNodeCallback=function(a,b,c,d){return b||(b=l),function(){var e=m.call(arguments,0);return new h(function(f){return b.schedule(function(){function b(a){if(a)return f.onError(a),void 0;var b=m.call(arguments,1);if(d)try{b=d(b)}catch(c){return f.onError(c),void 0}else 1===b.length&&(b=b[0]);f.onNext(b),f.onCompleted()}e.push(b),a.apply(c,e)})})}},f.fromEvent=function(a,b,c){return new h(function(d){return e(a,b,function(a){var b=a;if(c)try{b=c(arguments)}catch(e){return d.onError(e),void 0}d.onNext(b)})}).publish().refCount()},f.fromEventPattern=function(a,b,c){return new h(function(d){function e(a){var b=a;if(c)try{b=c(arguments)}catch(e){return d.onError(e),void 0}d.onNext(b)}var f=a(e);return j(function(){b&&b(e,f)})}).publish().refCount()},f.fromPromise=function(a){return new h(function(b){a.then(function(a){b.onNext(a),b.onCompleted()},function(a){b.onError(a)})})},g.toPromise=function(a){var b=this;return new a(function(a,c){var d,e=!1;b.subscribe(function(a){d=a,e=!0},function(a){c(a)},function(){e&&a(d)})})},c});
|
@@ -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){function d(){if(this.isDisposed)throw new Error(r)}var e=c.Observable,f=e.prototype,g=c.Internals.AnonymousObservable,h=c.Subject,i=c.AsyncSubject,j=c.Observer,k=c.Internals.ScheduledObserver,l=c.Disposable.create,m=c.Disposable.empty,n=c.CompositeDisposable,o=c.Scheduler.currentThread,p=c.Internals.inherits,q=c.Internals.addProperties,r="Object has been disposed";f.multicast=function(a,b){var c=this;return"function"==typeof a?new g(function(d){var e=c.multicast(a());return new n(b(e).subscribe(d),e.connect())}):new v(c,a)},f.publish=function(a){return a?this.multicast(function(){return new h},a):this.multicast(new h)},f.share=function(){return this.publish(null).refCount()},f.publishLast=function(a){return a?this.multicast(function(){return new i},a):this.multicast(new i)},f.publishValue=function(a,b){return 2===arguments.length?this.multicast(function(){return new t(b)},a):this.multicast(new t(a))},f.shareValue=function(a){return this.publishValue(a).refCount()},f.replay=function(a,b,c,d){return a?this.multicast(function(){return new u(b,c,d)},a):this.multicast(new u(b,c,d))},f.replayWhileObserved=function(a,b,c){return this.replay(null,a,b,c).refCount()};var s=function(a,b){this.subject=a,this.observer=b};s.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var a=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(a,1),this.observer=null}};var t=c.BehaviorSubject=function(a){function b(a){if(d.call(this),!this.isStopped)return this.observers.push(a),a.onNext(this.value),new s(this,a);var b=this.exception;return b?a.onError(b):a.onCompleted(),m}function c(c){a.call(this,b),this.value=c,this.observers=[],this.isDisposed=!1,this.isStopped=!1,this.exception=null}return p(c,a),q(c.prototype,j,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(d.call(this),!this.isStopped){var a=this.observers.slice(0);this.isStopped=!0;for(var b=0,c=a.length;c>b;b++)a[b].onCompleted();this.observers=[]}},onError:function(a){if(d.call(this),!this.isStopped){var b=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var c=0,e=b.length;e>c;c++)b[c].onError(a);this.observers=[]}},onNext:function(a){if(d.call(this),!this.isStopped){this.value=a;for(var b=this.observers.slice(0),c=0,e=b.length;e>c;c++)b[c].onNext(a)}},dispose:function(){this.isDisposed=!0,this.observers=null,this.value=null,this.exception=null}}),c}(e),u=c.ReplaySubject=function(a){function b(a,b){this.subject=a,this.observer=b}function c(a){var c=new k(this.scheduler,a),e=new b(this,c);d.call(this),this._trim(this.scheduler.now()),this.observers.push(c);for(var f=this.q.length,g=0,h=this.q.length;h>g;g++)c.onNext(this.q[g].value);return this.hasError?(f++,c.onError(this.error)):this.isStopped&&(f++,c.onCompleted()),c.ensureActive(f),e}function e(b,d,e){this.bufferSize=null==b?Number.MAX_VALUE:b,this.windowSize=null==d?Number.MAX_VALUE:d,this.scheduler=e||o,this.q=[],this.observers=[],this.isStopped=!1,this.isDisposed=!1,this.hasError=!1,this.error=null,a.call(this,c)}return b.prototype.dispose=function(){if(this.observer.dispose(),!this.subject.isDisposed){var a=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(a,1)}},p(e,a),q(e.prototype,j,{hasObservers:function(){return this.observers.length>0},_trim:function(a){for(;this.q.length>this.bufferSize;)this.q.shift();for(;this.q.length>0&&a-this.q[0].interval>this.windowSize;)this.q.shift()},onNext:function(a){var b;if(d.call(this),!this.isStopped){var c=this.scheduler.now();this.q.push({interval:c,value:a}),this._trim(c);for(var e=this.observers.slice(0),f=0,g=e.length;g>f;f++)b=e[f],b.onNext(a),b.ensureActive()}},onError:function(a){var b;if(d.call(this),!this.isStopped){this.isStopped=!0,this.error=a,this.hasError=!0;var c=this.scheduler.now();this._trim(c);for(var e=this.observers.slice(0),f=0,g=e.length;g>f;f++)b=e[f],b.onError(a),b.ensureActive();this.observers=[]}},onCompleted:function(){var a;if(d.call(this),!this.isStopped){this.isStopped=!0;var b=this.scheduler.now();this._trim(b);for(var c=this.observers.slice(0),e=0,f=c.length;f>e;e++)a=c[e],a.onCompleted(),a.ensureActive();this.observers=[]}},dispose:function(){this.isDisposed=!0,this.observers=null}}),e}(e),v=function(a){function b(b,c){function d(a){return e.subject.subscribe(a)}var e={subject:c,source:b.asObservable(),hasSubscription:!1,subscription:null};this.connect=function(){return e.hasSubscription||(e.hasSubscription=!0,e.subscription=new n(e.source.subscribe(e.subject),l(function(){e.hasSubscription=!1}))),e.subscription},a.call(this,d)}return p(b,a),b.prototype.connect=function(){return this.connect()},b.prototype.refCount=function(){var a=null,b=0,c=this;return new g(function(d){var e,f;return b++,e=1===b,f=c.subscribe(d),e&&(a=c.connect()),l(function(){f.dispose(),b--,0===b&&a.dispose()})})},b}(e);return 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){function d(){if(this.isDisposed)throw new Error(r)}var e=c.Observable,f=e.prototype,g=c.Internals.AnonymousObservable,h=c.Subject,i=c.AsyncSubject,j=c.Observer,k=c.Internals.ScheduledObserver,l=c.Disposable.create,m=c.Disposable.empty,n=c.CompositeDisposable,o=c.Scheduler.currentThread,p=c.Internals.inherits,q=c.Internals.addProperties,r="Object has been disposed";f.multicast=function(a,b){var c=this;return"function"==typeof a?new g(function(d){var e=c.multicast(a());return new n(b(e).subscribe(d),e.connect())}):new v(c,a)},f.publish=function(a){return a?this.multicast(function(){return new h},a):this.multicast(new h)},f.share=function(){return this.publish(null).refCount()},f.publishLast=function(a){return a?this.multicast(function(){return new i},a):this.multicast(new i)},f.publishValue=function(a,b){return 2===arguments.length?this.multicast(function(){return new t(b)},a):this.multicast(new t(a))},f.shareValue=function(a){return this.publishValue(a).refCount()},f.replay=function(a,b,c,d){return a?this.multicast(function(){return new u(b,c,d)},a):this.multicast(new u(b,c,d))},f.replayWhileObserved=function(a,b,c){return this.replay(null,a,b,c).refCount()};var s=function(a,b){this.subject=a,this.observer=b};s.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var a=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(a,1),this.observer=null}};var t=c.BehaviorSubject=function(a){function b(a){if(d.call(this),!this.isStopped)return this.observers.push(a),a.onNext(this.value),new s(this,a);var b=this.exception;return b?a.onError(b):a.onCompleted(),m}function c(c){a.call(this,b),this.value=c,this.observers=[],this.isDisposed=!1,this.isStopped=!1,this.exception=null}return p(c,a),q(c.prototype,j,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(d.call(this),!this.isStopped){var a=this.observers.slice(0);this.isStopped=!0;for(var b=0,c=a.length;c>b;b++)a[b].onCompleted();this.observers=[]}},onError:function(a){if(d.call(this),!this.isStopped){var b=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var c=0,e=b.length;e>c;c++)b[c].onError(a);this.observers=[]}},onNext:function(a){if(d.call(this),!this.isStopped){this.value=a;for(var b=this.observers.slice(0),c=0,e=b.length;e>c;c++)b[c].onNext(a)}},dispose:function(){this.isDisposed=!0,this.observers=null,this.value=null,this.exception=null}}),c}(e),u=c.ReplaySubject=function(a){function b(a,b){this.subject=a,this.observer=b}function c(a){var c=new k(this.scheduler,a),e=new b(this,c);d.call(this),this._trim(this.scheduler.now()),this.observers.push(c);for(var f=this.q.length,g=0,h=this.q.length;h>g;g++)c.onNext(this.q[g].value);return this.hasError?(f++,c.onError(this.error)):this.isStopped&&(f++,c.onCompleted()),c.ensureActive(f),e}function e(b,d,e){this.bufferSize=null==b?Number.MAX_VALUE:b,this.windowSize=null==d?Number.MAX_VALUE:d,this.scheduler=e||o,this.q=[],this.observers=[],this.isStopped=!1,this.isDisposed=!1,this.hasError=!1,this.error=null,a.call(this,c)}return b.prototype.dispose=function(){if(this.observer.dispose(),!this.subject.isDisposed){var a=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(a,1)}},p(e,a),q(e.prototype,j,{hasObservers:function(){return this.observers.length>0},_trim:function(a){for(;this.q.length>this.bufferSize;)this.q.shift();for(;this.q.length>0&&a-this.q[0].interval>this.windowSize;)this.q.shift()},onNext:function(a){var b;if(d.call(this),!this.isStopped){var c=this.scheduler.now();this.q.push({interval:c,value:a}),this._trim(c);for(var e=this.observers.slice(0),f=0,g=e.length;g>f;f++)b=e[f],b.onNext(a),b.ensureActive()}},onError:function(a){var b;if(d.call(this),!this.isStopped){this.isStopped=!0,this.error=a,this.hasError=!0;var c=this.scheduler.now();this._trim(c);for(var e=this.observers.slice(0),f=0,g=e.length;g>f;f++)b=e[f],b.onError(a),b.ensureActive();this.observers=[]}},onCompleted:function(){var a;if(d.call(this),!this.isStopped){this.isStopped=!0;var b=this.scheduler.now();this._trim(b);for(var c=this.observers.slice(0),e=0,f=c.length;f>e;e++)a=c[e],a.onCompleted(),a.ensureActive();this.observers=[]}},dispose:function(){this.isDisposed=!0,this.observers=null}}),e}(e),v=c.ConnectableObservable=function(a){function b(b,c){function d(a){return e.subject.subscribe(a)}var e={subject:c,source:b.asObservable(),hasSubscription:!1,subscription:null};this.connect=function(){return e.hasSubscription||(e.hasSubscription=!0,e.subscription=new n(e.source.subscribe(e.subject),l(function(){e.hasSubscription=!1}))),e.subscription},a.call(this,d)}return p(b,a),b.prototype.connect=function(){return this.connect()},b.prototype.refCount=function(){var a=null,b=0,c=this;return new g(function(d){var e,f;return b++,e=1===b,f=c.subscribe(d),e&&(a=c.connect()),l(function(){f.dispose(),b--,0===b&&a.dispose()})})},b}(e);return c});
|