rxjs-rails 0.0.1
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 +7 -0
- data/Gemfile +3 -0
- data/LICENSE +19 -0
- data/README.md +14 -0
- data/lib/rxjs/rails/engine.rb +7 -0
- data/lib/rxjs/rails/railtie.rb +7 -0
- data/lib/rxjs/rails/version.rb +7 -0
- data/lib/rxjs/rails.rb +8 -0
- data/lib/rxjs.rb +1 -0
- data/rxjs-rails.gemspec +22 -0
- data/vendor/assets/javascripts/rx.aggregates.js +687 -0
- data/vendor/assets/javascripts/rx.aggregates.min.js +1 -0
- data/vendor/assets/javascripts/rx.async.compat.js +376 -0
- data/vendor/assets/javascripts/rx.async.compat.min.js +1 -0
- data/vendor/assets/javascripts/rx.async.js +306 -0
- data/vendor/assets/javascripts/rx.async.min.js +1 -0
- data/vendor/assets/javascripts/rx.binding.js +561 -0
- data/vendor/assets/javascripts/rx.binding.min.js +1 -0
- data/vendor/assets/javascripts/rx.coincidence.js +691 -0
- data/vendor/assets/javascripts/rx.coincidence.min.js +1 -0
- data/vendor/assets/javascripts/rx.compat.js +4351 -0
- data/vendor/assets/javascripts/rx.compat.min.js +2 -0
- data/vendor/assets/javascripts/rx.experimental.js +453 -0
- data/vendor/assets/javascripts/rx.experimental.min.js +1 -0
- data/vendor/assets/javascripts/rx.joinpatterns.js +418 -0
- data/vendor/assets/javascripts/rx.joinpatterns.min.js +1 -0
- data/vendor/assets/javascripts/rx.lite.compat.js +5188 -0
- data/vendor/assets/javascripts/rx.lite.compat.min.js +2 -0
- data/vendor/assets/javascripts/rx.lite.js +5000 -0
- data/vendor/assets/javascripts/rx.lite.min.js +2 -0
- data/vendor/assets/javascripts/rx.min.js +2 -0
- data/vendor/assets/javascripts/rx.node.js +143 -0
- data/vendor/assets/javascripts/rx.testing.js +503 -0
- data/vendor/assets/javascripts/rx.testing.min.js +1 -0
- data/vendor/assets/javascripts/rx.time.js +1166 -0
- data/vendor/assets/javascripts/rx.time.min.js +1 -0
- data/vendor/assets/javascripts/rx.virtualtime.js +336 -0
- data/vendor/assets/javascripts/rx.virtualtime.min.js +1 -0
- metadata +101 -0
@@ -0,0 +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 new n(function(c){return b.scheduleWithAbsolute(a,function(){c.onNext(0),c.onCompleted()})})}function f(a,b,c){var d=A(b);return new n(function(b){var e=0,f=a;return c.scheduleRecursiveWithAbsolute(f,function(a){var g;d>0&&(g=c.now(),f+=d,g>=f&&(f=g+d)),b.onNext(e++),a(f)})})}function g(a,b){var c=A(a);return new n(function(a){return b.scheduleWithRelative(c,function(){a.onNext(0),a.onCompleted()})})}function h(a,b,c){return a===b?new n(function(a){return c.schedulePeriodicWithState(0,b,function(b){return a.onNext(b),b+1})}):o(function(){return f(c.now()+a,b,c)})}function i(a,b){var c=this;return new n(function(d){var e,f=!1,g=new v,h=null,i=[],j=!1;return e=c.materialize().timestamp(b).subscribe(function(c){var e,k;"E"===c.value.kind?(i=[],i.push(c),h=c.value.exception,k=!j):(i.push({value:c.value,timestamp:c.timestamp+a}),k=!f,f=!0),k&&(null!==h?d.onError(h):(e=new u,g.setDisposable(e),e.setDisposable(b.scheduleRecursiveWithRelative(a,function(a){var c,e,g,k;if(null===h){j=!0;do g=null,i.length>0&&i[0].timestamp-b.now()<=0&&(g=i.shift().value),null!==g&&g.accept(d);while(null!==g);k=!1,e=0,i.length>0?(k=!0,e=Math.max(0,i[0].timestamp-b.now())):f=!1,c=h,j=!1,null!==c?d.onError(c):k&&a(e)}}))))}),new w(e,g)})}function j(a,b){var c=this;return o(function(){var d=a-b.now();return i.call(c,d,b)})}function k(a,b){return new n(function(c){function d(){g&&(g=!1,c.onNext(f)),e&&c.onCompleted()}var e,f,g;return new w(a.subscribe(function(a){g=!0,f=a},c.onError.bind(c),function(){e=!0}),b.subscribe(d,c.onError.bind(c),d))})}var l=c.Observable,m=l.prototype,n=c.Internals.AnonymousObservable,o=l.defer,p=l.empty,q=l.never,r=l.throwException,s=l.fromArray,t=c.Scheduler.timeout,u=c.SingleAssignmentDisposable,v=c.SerialDisposable,w=c.CompositeDisposable,x=c.RefCountDisposable,y=c.Subject,z=(c.Internals.BinaryObserver,c.Internals.addRef),A=c.Scheduler.normalize,B=l.interval=function(a,b){return b||(b=t),h(a,a,b)},C=l.timer=function(a,b,c){var i;return c||(c=t),b!==d&&"number"==typeof b?i=b:b!==d&&"object"==typeof b&&(c=b),a instanceof Date&&i===d?e(a.getTime(),c):a instanceof Date&&i!==d?(i=b,f(a.getTime(),i,c)):i===d?g(a,c):h(a,i,c)};return m.delay=function(a,b){return b||(b=t),a instanceof Date?j.call(this,a.getTime(),b):i.call(this,a,b)},m.throttle=function(a,b){b||(b=t);return this.throttleWithSelector(function(){return C(a,b)})},m.windowWithTime=function(a,b,c){var e,f=this;return b===d&&(e=a),c===d&&(c=t),"number"==typeof b?e=b:"object"==typeof b&&(e=a,c=b),new n(function(b){function d(){var a=new u,f=!1,g=!1;l.setDisposable(a),j===i?(f=!0,g=!0):i>j?f=!0:g=!0;var n=f?j:i,o=n-m;m=n,f&&(j+=e),g&&(i+=e),a.setDisposable(c.scheduleWithRelative(o,function(){var a;g&&(a=new y,k.push(a),b.onNext(z(a,h))),f&&(a=k.shift(),a.onCompleted()),d()}))}var g,h,i=e,j=a,k=[],l=new v,m=0;return g=new w(l),h=new x(g),k.push(new y),b.onNext(z(k[0],h)),d(),g.add(f.subscribe(function(a){var b,c;for(b=0;b<k.length;b++)c=k[b],c.onNext(a)},function(a){var c,d;for(c=0;c<k.length;c++)d=k[c],d.onError(a);b.onError(a)},function(){var a,c;for(a=0;a<k.length;a++)c=k[a],c.onCompleted();b.onCompleted()})),h})},m.windowWithTimeOrCount=function(a,b,c){var d=this;return c||(c=t),new n(function(e){var f,g,h,i,j=0,k=new v,l=0;return g=new w(k),h=new x(g),f=function(b){var d=new u;k.setDisposable(d),d.setDisposable(c.scheduleWithRelative(a,function(){var a;b===l&&(j=0,a=++l,i.onCompleted(),i=new y,e.onNext(z(i,h)),f(a))}))},i=new y,e.onNext(z(i,h)),f(0),g.add(d.subscribe(function(a){var c=0,d=!1;i.onNext(a),j++,j===b&&(d=!0,j=0,c=++l,i.onCompleted(),i=new y,e.onNext(z(i,h))),d&&f(c)},function(a){i.onError(a),e.onError(a)},function(){i.onCompleted(),e.onCompleted()})),h})},m.bufferWithTime=function(){return this.windowWithTime.apply(this,arguments).selectMany(function(a){return a.toArray()})},m.bufferWithTimeOrCount=function(a,b,c){return this.windowWithTimeOrCount(a,b,c).selectMany(function(a){return a.toArray()})},m.timeInterval=function(a){var b=this;return a||(a=t),o(function(){var c=a.now();return b.select(function(b){var d=a.now(),e=d-c;return c=d,{value:b,interval:e}})})},m.timestamp=function(a){return a||(a=t),this.select(function(b){return{value:b,timestamp:a.now()}})},m.sample=function(a,b){return b||(b=t),"number"==typeof a?k(this,B(a,b)):k(this,a)},m.timeout=function(a,b,c){var d,e=this;return b||(b=r(new Error("Timeout"))),c||(c=t),d=a instanceof Date?function(a,b){c.scheduleWithAbsolute(a,b)}:function(a,b){c.scheduleWithRelative(a,b)},new n(function(c){var f,g=0,h=new u,i=new v,j=!1,k=new v;return i.setDisposable(h),f=function(){var e=g;k.setDisposable(d(a,function(){j=g===e;var a=j;a&&i.setDisposable(b.subscribe(c))}))},f(),h.setDisposable(e.subscribe(function(a){var b=!j;b&&(g++,c.onNext(a),f())},function(a){var b=!j;b&&(g++,c.onError(a))},function(){var a=!j;a&&(g++,c.onCompleted())})),new w(i,k)})},l.generateWithAbsoluteTime=function(a,b,c,d,e,f){return f||(f=t),new n(function(g){var h,i,j=!0,k=!1,l=a;return f.scheduleRecursiveWithAbsolute(f.now(),function(a){k&&g.onNext(h);try{j?j=!1:l=c(l),k=b(l),k&&(h=d(l),i=e(l))}catch(f){return g.onError(f),void 0}k?a(i):g.onCompleted()})})},l.generateWithRelativeTime=function(a,b,c,d,e,f){return f||(f=t),new n(function(g){var h,i,j=!0,k=!1,l=a;return f.scheduleRecursiveWithRelative(0,function(a){k&&g.onNext(h);try{j?j=!1:l=c(l),k=b(l),k&&(h=d(l),i=e(l))}catch(f){return g.onError(f),void 0}k?a(i):g.onCompleted()})})},m.delaySubscription=function(a,b){return b||(b=t),this.delayWithSelector(C(a,b),function(){return p()})},m.delayWithSelector=function(a,b){var c,d,e=this;return"function"==typeof a?d=a:(c=a,d=b),new n(function(a){var b=new w,f=!1,g=function(){f&&0===b.length&&a.onCompleted()},h=new v,i=function(){h.setDisposable(e.subscribe(function(c){var e;try{e=d(c)}catch(f){return a.onError(f),void 0}var h=new u;b.add(h),h.setDisposable(e.subscribe(function(){a.onNext(c),b.remove(h),g()},a.onError.bind(a),function(){a.onNext(c),b.remove(h),g()}))},a.onError.bind(a),function(){f=!0,h.dispose(),g()}))};return c?h.setDisposable(c.subscribe(function(){i()},a.onError.bind(a),function(){i()})):i(),new w(h,b)})},m.timeoutWithSelector=function(a,b,c){if(1===arguments.length){b=a;var a=q()}c||(c=r(new Error("Timeout")));var d=this;return new n(function(e){var f=new v,g=new v,h=new u;f.setDisposable(h);var i=0,j=!1,k=function(a){var b=i,d=function(){return i===b},h=new u;g.setDisposable(h),h.setDisposable(a.subscribe(function(){d()&&f.setDisposable(c.subscribe(e)),h.dispose()},function(a){d()&&e.onError(a)},function(){d()&&f.setDisposable(c.subscribe(e))}))};k(a);var l=function(){var a=!j;return a&&i++,a};return h.setDisposable(d.subscribe(function(a){if(l()){e.onNext(a);var c;try{c=b(a)}catch(d){return e.onError(d),void 0}k(c)}},function(a){l()&&e.onError(a)},function(){l()&&e.onCompleted()})),new w(f,g)})},m.throttleWithSelector=function(a){var b=this;return new n(function(c){var d,e=!1,f=new v,g=0,h=b.subscribe(function(b){var h;try{h=a(b)}catch(i){return c.onError(i),void 0}e=!0,d=b,g++;var j=g,k=new u;f.setDisposable(k),k.setDisposable(h.subscribe(function(){e&&g===j&&c.onNext(d),e=!1,k.dispose()},c.onError.bind(c),function(){e&&g===j&&c.onNext(d),e=!1,k.dispose()}))},function(a){f.dispose(),c.onError(a),e=!1,g++},function(){f.dispose(),e&&c.onNext(d),c.onCompleted(),e=!1,g++});return new w(h,f)})},m.skipLastWithTime=function(a,b){b||(b=t);var c=this;return new n(function(d){var e=[];return c.subscribe(function(c){var f=b.now();for(e.push({interval:f,value:c});e.length>0&&f-e[0].interval>=a;)d.onNext(e.shift().value)},d.onError.bind(d),function(){for(var c=b.now();e.length>0&&c-e[0].interval>=a;)d.onNext(e.shift().value);d.onCompleted()})})},m.takeLastWithTime=function(a,b,c){return this.takeLastBufferWithTime(a,b).selectMany(function(a){return s(a,c)})},m.takeLastBufferWithTime=function(a,b){var c=this;return b||(b=t),new n(function(d){var e=[];return c.subscribe(function(c){var d=b.now();for(e.push({interval:d,value:c});e.length>0&&d-e[0].interval>=a;)e.shift()},d.onError.bind(d),function(){for(var c=b.now(),f=[];e.length>0;){var g=e.shift();c-g.interval<=a&&f.push(g.value)}d.onNext(f),d.onCompleted()})})},m.takeWithTime=function(a,b){var c=this;return b||(b=t),new n(function(d){var e=b.scheduleWithRelative(a,function(){d.onCompleted()});return new w(e,c.subscribe(d))})},m.skipWithTime=function(a,b){var c=this;return b||(b=t),new n(function(d){var e=!1,f=b.scheduleWithRelative(a,function(){e=!0}),g=c.subscribe(function(a){e&&d.onNext(a)},d.onError.bind(d),d.onCompleted.bind(d));return new w(f,g)})},m.skipUntilWithTime=function(a,b){b||(b=t);var c=this;return new n(function(d){var e=!1,f=b.scheduleWithAbsolute(a,function(){e=!0}),g=c.subscribe(function(a){e&&d.onNext(a)},d.onError.bind(d),d.onCompleted.bind(d));return new w(f,g)})},m.takeUntilWithTime=function(a,b){b||(b=t);var c=this;return new n(function(d){return new w(b.scheduleWithAbsolute(a,function(){d.onCompleted()}),c.subscribe(d))})},c});
|
@@ -0,0 +1,336 @@
|
|
1
|
+
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
|
2
|
+
|
3
|
+
;(function (factory) {
|
4
|
+
var objectTypes = {
|
5
|
+
'boolean': false,
|
6
|
+
'function': true,
|
7
|
+
'object': true,
|
8
|
+
'number': false,
|
9
|
+
'string': false,
|
10
|
+
'undefined': false
|
11
|
+
};
|
12
|
+
|
13
|
+
var root = (objectTypes[typeof window] && window) || this,
|
14
|
+
freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports,
|
15
|
+
freeModule = objectTypes[typeof module] && module && !module.nodeType && module,
|
16
|
+
moduleExports = freeModule && freeModule.exports === freeExports && freeExports,
|
17
|
+
freeGlobal = objectTypes[typeof global] && global;
|
18
|
+
|
19
|
+
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
|
20
|
+
root = freeGlobal;
|
21
|
+
}
|
22
|
+
|
23
|
+
// Because of build optimizers
|
24
|
+
if (typeof define === 'function' && define.amd) {
|
25
|
+
define(['rx', 'exports'], function (Rx, exports) {
|
26
|
+
root.Rx = factory(root, exports, Rx);
|
27
|
+
return root.Rx;
|
28
|
+
});
|
29
|
+
} else if (typeof module === 'object' && module && module.exports === freeExports) {
|
30
|
+
module.exports = factory(root, module.exports, require('./rx'));
|
31
|
+
} else {
|
32
|
+
root.Rx = factory(root, {}, root.Rx);
|
33
|
+
}
|
34
|
+
}.call(this, function (root, exp, Rx, undefined) {
|
35
|
+
|
36
|
+
// Aliases
|
37
|
+
var Scheduler = Rx.Scheduler,
|
38
|
+
PriorityQueue = Rx.Internals.PriorityQueue,
|
39
|
+
ScheduledItem = Rx.Internals.ScheduledItem,
|
40
|
+
SchedulePeriodicRecursive = Rx.Internals.SchedulePeriodicRecursive,
|
41
|
+
disposableEmpty = Rx.Disposable.empty,
|
42
|
+
inherits = Rx.Internals.inherits;
|
43
|
+
|
44
|
+
function defaultSubComparer(x, y) { return x - y; }
|
45
|
+
|
46
|
+
/** Provides a set of extension methods for virtual time scheduling. */
|
47
|
+
Rx.VirtualTimeScheduler = (function (_super) {
|
48
|
+
|
49
|
+
function notImplemented() {
|
50
|
+
throw new Error('Not implemented');
|
51
|
+
}
|
52
|
+
|
53
|
+
function localNow() {
|
54
|
+
return this.toDateTimeOffset(this.clock);
|
55
|
+
}
|
56
|
+
|
57
|
+
function scheduleNow(state, action) {
|
58
|
+
return this.scheduleAbsoluteWithState(state, this.clock, action);
|
59
|
+
}
|
60
|
+
|
61
|
+
function scheduleRelative(state, dueTime, action) {
|
62
|
+
return this.scheduleRelativeWithState(state, this.toRelative(dueTime), action);
|
63
|
+
}
|
64
|
+
|
65
|
+
function scheduleAbsolute(state, dueTime, action) {
|
66
|
+
return this.scheduleRelativeWithState(state, this.toRelative(dueTime - this.now()), action);
|
67
|
+
}
|
68
|
+
|
69
|
+
function invokeAction(scheduler, action) {
|
70
|
+
action();
|
71
|
+
return disposableEmpty;
|
72
|
+
}
|
73
|
+
|
74
|
+
inherits(VirtualTimeScheduler, _super);
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Creates a new virtual time scheduler with the specified initial clock value and absolute time comparer.
|
78
|
+
*
|
79
|
+
* @constructor
|
80
|
+
* @param {Number} initialClock Initial value for the clock.
|
81
|
+
* @param {Function} comparer Comparer to determine causality of events based on absolute time.
|
82
|
+
*/
|
83
|
+
function VirtualTimeScheduler(initialClock, comparer) {
|
84
|
+
this.clock = initialClock;
|
85
|
+
this.comparer = comparer;
|
86
|
+
this.isEnabled = false;
|
87
|
+
this.queue = new PriorityQueue(1024);
|
88
|
+
_super.call(this, localNow, scheduleNow, scheduleRelative, scheduleAbsolute);
|
89
|
+
}
|
90
|
+
|
91
|
+
var VirtualTimeSchedulerPrototype = VirtualTimeScheduler.prototype;
|
92
|
+
|
93
|
+
/**
|
94
|
+
* Adds a relative time value to an absolute time value.
|
95
|
+
* @param {Number} absolute Absolute virtual time value.
|
96
|
+
* @param {Number} relative Relative virtual time value to add.
|
97
|
+
* @return {Number} Resulting absolute virtual time sum value.
|
98
|
+
*/
|
99
|
+
VirtualTimeSchedulerPrototype.add = notImplemented;
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Converts an absolute time to a number
|
103
|
+
* @param {Any} The absolute time.
|
104
|
+
* @returns {Number} The absolute time in ms
|
105
|
+
*/
|
106
|
+
VirtualTimeSchedulerPrototype.toDateTimeOffset = notImplemented;
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Converts the TimeSpan value to a relative virtual time value.
|
110
|
+
* @param {Number} timeSpan TimeSpan value to convert.
|
111
|
+
* @return {Number} Corresponding relative virtual time value.
|
112
|
+
*/
|
113
|
+
VirtualTimeSchedulerPrototype.toRelative = notImplemented;
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be emulated using recursive scheduling.
|
117
|
+
* @param {Mixed} state Initial state passed to the action upon the first iteration.
|
118
|
+
* @param {Number} period Period for running the work periodically.
|
119
|
+
* @param {Function} action Action to be executed, potentially updating the state.
|
120
|
+
* @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).
|
121
|
+
*/
|
122
|
+
VirtualTimeSchedulerPrototype.schedulePeriodicWithState = function (state, period, action) {
|
123
|
+
var s = new SchedulePeriodicRecursive(this, state, period, action);
|
124
|
+
return s.start();
|
125
|
+
};
|
126
|
+
|
127
|
+
/**
|
128
|
+
* Schedules an action to be executed after dueTime.
|
129
|
+
* @param {Mixed} state State passed to the action to be executed.
|
130
|
+
* @param {Number} dueTime Relative time after which to execute the action.
|
131
|
+
* @param {Function} action Action to be executed.
|
132
|
+
* @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
|
133
|
+
*/
|
134
|
+
VirtualTimeSchedulerPrototype.scheduleRelativeWithState = function (state, dueTime, action) {
|
135
|
+
var runAt = this.add(this.clock, dueTime);
|
136
|
+
return this.scheduleAbsoluteWithState(state, runAt, action);
|
137
|
+
};
|
138
|
+
|
139
|
+
/**
|
140
|
+
* Schedules an action to be executed at dueTime.
|
141
|
+
* @param {Number} dueTime Relative time after which to execute the action.
|
142
|
+
* @param {Function} action Action to be executed.
|
143
|
+
* @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
|
144
|
+
*/
|
145
|
+
VirtualTimeSchedulerPrototype.scheduleRelative = function (dueTime, action) {
|
146
|
+
return this.scheduleRelativeWithState(action, dueTime, invokeAction);
|
147
|
+
};
|
148
|
+
|
149
|
+
/**
|
150
|
+
* Starts the virtual time scheduler.
|
151
|
+
*/
|
152
|
+
VirtualTimeSchedulerPrototype.start = function () {
|
153
|
+
var next;
|
154
|
+
if (!this.isEnabled) {
|
155
|
+
this.isEnabled = true;
|
156
|
+
do {
|
157
|
+
next = this.getNext();
|
158
|
+
if (next !== null) {
|
159
|
+
if (this.comparer(next.dueTime, this.clock) > 0) {
|
160
|
+
this.clock = next.dueTime;
|
161
|
+
}
|
162
|
+
next.invoke();
|
163
|
+
} else {
|
164
|
+
this.isEnabled = false;
|
165
|
+
}
|
166
|
+
} while (this.isEnabled);
|
167
|
+
}
|
168
|
+
};
|
169
|
+
|
170
|
+
/**
|
171
|
+
* Stops the virtual time scheduler.
|
172
|
+
*/
|
173
|
+
VirtualTimeSchedulerPrototype.stop = function () {
|
174
|
+
this.isEnabled = false;
|
175
|
+
};
|
176
|
+
|
177
|
+
/**
|
178
|
+
* Advances the scheduler's clock to the specified time, running all work till that point.
|
179
|
+
* @param {Number} time Absolute time to advance the scheduler's clock to.
|
180
|
+
*/
|
181
|
+
VirtualTimeSchedulerPrototype.advanceTo = function (time) {
|
182
|
+
var next;
|
183
|
+
var dueToClock = this.comparer(this.clock, time);
|
184
|
+
if (this.comparer(this.clock, time) > 0) {
|
185
|
+
throw new Error(argumentOutOfRange);
|
186
|
+
}
|
187
|
+
if (dueToClock === 0) {
|
188
|
+
return;
|
189
|
+
}
|
190
|
+
if (!this.isEnabled) {
|
191
|
+
this.isEnabled = true;
|
192
|
+
do {
|
193
|
+
next = this.getNext();
|
194
|
+
if (next !== null && this.comparer(next.dueTime, time) <= 0) {
|
195
|
+
if (this.comparer(next.dueTime, this.clock) > 0) {
|
196
|
+
this.clock = next.dueTime;
|
197
|
+
}
|
198
|
+
next.invoke();
|
199
|
+
} else {
|
200
|
+
this.isEnabled = false;
|
201
|
+
}
|
202
|
+
} while (this.isEnabled);
|
203
|
+
this.clock = time;
|
204
|
+
}
|
205
|
+
};
|
206
|
+
|
207
|
+
/**
|
208
|
+
* Advances the scheduler's clock by the specified relative time, running all work scheduled for that timespan.
|
209
|
+
* @param {Number} time Relative time to advance the scheduler's clock by.
|
210
|
+
*/
|
211
|
+
VirtualTimeSchedulerPrototype.advanceBy = function (time) {
|
212
|
+
var dt = this.add(this.clock, time);
|
213
|
+
var dueToClock = this.comparer(this.clock, dt);
|
214
|
+
if (dueToClock > 0) {
|
215
|
+
throw new Error(argumentOutOfRange);
|
216
|
+
}
|
217
|
+
if (dueToClock === 0) {
|
218
|
+
return;
|
219
|
+
}
|
220
|
+
this.advanceTo(dt);
|
221
|
+
};
|
222
|
+
|
223
|
+
/**
|
224
|
+
* Advances the scheduler's clock by the specified relative time.
|
225
|
+
* @param {Number} time Relative time to advance the scheduler's clock by.
|
226
|
+
*/
|
227
|
+
VirtualTimeSchedulerPrototype.sleep = function (time) {
|
228
|
+
var dt = this.add(this.clock, time);
|
229
|
+
|
230
|
+
if (this.comparer(this.clock, dt) >= 0) {
|
231
|
+
throw new Error(argumentOutOfRange);
|
232
|
+
}
|
233
|
+
|
234
|
+
this.clock = dt;
|
235
|
+
};
|
236
|
+
|
237
|
+
/**
|
238
|
+
* Gets the next scheduled item to be executed.
|
239
|
+
* @returns {ScheduledItem} The next scheduled item.
|
240
|
+
*/
|
241
|
+
VirtualTimeSchedulerPrototype.getNext = function () {
|
242
|
+
var next;
|
243
|
+
while (this.queue.length > 0) {
|
244
|
+
next = this.queue.peek();
|
245
|
+
if (next.isCancelled()) {
|
246
|
+
this.queue.dequeue();
|
247
|
+
} else {
|
248
|
+
return next;
|
249
|
+
}
|
250
|
+
}
|
251
|
+
return null;
|
252
|
+
};
|
253
|
+
|
254
|
+
/**
|
255
|
+
* Schedules an action to be executed at dueTime.
|
256
|
+
* @param {Scheduler} scheduler Scheduler to execute the action on.
|
257
|
+
* @param {Number} dueTime Absolute time at which to execute the action.
|
258
|
+
* @param {Function} action Action to be executed.
|
259
|
+
* @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
|
260
|
+
*/
|
261
|
+
VirtualTimeSchedulerPrototype.scheduleAbsolute = function (dueTime, action) {
|
262
|
+
return this.scheduleAbsoluteWithState(action, dueTime, invokeAction);
|
263
|
+
};
|
264
|
+
|
265
|
+
/**
|
266
|
+
* Schedules an action to be executed at dueTime.
|
267
|
+
* @param {Mixed} state State passed to the action to be executed.
|
268
|
+
* @param {Number} dueTime Absolute time at which to execute the action.
|
269
|
+
* @param {Function} action Action to be executed.
|
270
|
+
* @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
|
271
|
+
*/
|
272
|
+
VirtualTimeSchedulerPrototype.scheduleAbsoluteWithState = function (state, dueTime, action) {
|
273
|
+
var self = this,
|
274
|
+
run = function (scheduler, state1) {
|
275
|
+
self.queue.remove(si);
|
276
|
+
return action(scheduler, state1);
|
277
|
+
},
|
278
|
+
si = new ScheduledItem(self, state, run, dueTime, self.comparer);
|
279
|
+
self.queue.enqueue(si);
|
280
|
+
return si.disposable;
|
281
|
+
};
|
282
|
+
|
283
|
+
return VirtualTimeScheduler;
|
284
|
+
}(Scheduler));
|
285
|
+
|
286
|
+
/** Provides a virtual time scheduler that uses Date for absolute time and number for relative time. */
|
287
|
+
Rx.HistoricalScheduler = (function (_super) {
|
288
|
+
inherits(HistoricalScheduler, _super);
|
289
|
+
|
290
|
+
/**
|
291
|
+
* Creates a new historical scheduler with the specified initial clock value.
|
292
|
+
*
|
293
|
+
* @constructor
|
294
|
+
* @param {Number} initialClock Initial value for the clock.
|
295
|
+
* @param {Function} comparer Comparer to determine causality of events based on absolute time.
|
296
|
+
*/
|
297
|
+
function HistoricalScheduler(initialClock, comparer) {
|
298
|
+
var clock = initialClock == null ? 0 : initialClock;
|
299
|
+
var cmp = comparer || defaultSubComparer;
|
300
|
+
_super.call(this, clock, cmp);
|
301
|
+
}
|
302
|
+
|
303
|
+
var HistoricalSchedulerProto = HistoricalScheduler.prototype;
|
304
|
+
|
305
|
+
/**
|
306
|
+
* Adds a relative time value to an absolute time value.
|
307
|
+
* @param {Number} absolute Absolute virtual time value.
|
308
|
+
* @param {Number} relative Relative virtual time value to add.
|
309
|
+
* @return {Number} Resulting absolute virtual time sum value.
|
310
|
+
*/
|
311
|
+
HistoricalSchedulerProto.add = function (absolute, relative) {
|
312
|
+
return absolute + relative;
|
313
|
+
};
|
314
|
+
|
315
|
+
/**
|
316
|
+
* @private
|
317
|
+
*/
|
318
|
+
HistoricalSchedulerProto.toDateTimeOffset = function (absolute) {
|
319
|
+
return new Date(absolute).getTime();
|
320
|
+
};
|
321
|
+
|
322
|
+
/**
|
323
|
+
* Converts the TimeSpan value to a relative virtual time value.
|
324
|
+
*
|
325
|
+
* @memberOf HistoricalScheduler
|
326
|
+
* @param {Number} timeSpan TimeSpan value to convert.
|
327
|
+
* @return {Number} Corresponding relative virtual time value.
|
328
|
+
*/
|
329
|
+
HistoricalSchedulerProto.toRelative = function (timeSpan) {
|
330
|
+
return timeSpan;
|
331
|
+
};
|
332
|
+
|
333
|
+
return HistoricalScheduler;
|
334
|
+
}(Rx.VirtualTimeScheduler));
|
335
|
+
return Rx;
|
336
|
+
}));
|
@@ -0,0 +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){return a-b}var e=c.Scheduler,f=c.Internals.PriorityQueue,g=c.Internals.ScheduledItem,h=c.Internals.SchedulePeriodicRecursive,i=c.Disposable.empty,j=c.Internals.inherits;return c.VirtualTimeScheduler=function(a){function b(){throw new Error("Not implemented")}function c(){return this.toDateTimeOffset(this.clock)}function d(a,b){return this.scheduleAbsoluteWithState(a,this.clock,b)}function e(a,b,c){return this.scheduleRelativeWithState(a,this.toRelative(b),c)}function k(a,b,c){return this.scheduleRelativeWithState(a,this.toRelative(b-this.now()),c)}function l(a,b){return b(),i}function m(b,g){this.clock=b,this.comparer=g,this.isEnabled=!1,this.queue=new f(1024),a.call(this,c,d,e,k)}j(m,a);var n=m.prototype;return n.add=b,n.toDateTimeOffset=b,n.toRelative=b,n.schedulePeriodicWithState=function(a,b,c){var d=new h(this,a,b,c);return d.start()},n.scheduleRelativeWithState=function(a,b,c){var d=this.add(this.clock,b);return this.scheduleAbsoluteWithState(a,d,c)},n.scheduleRelative=function(a,b){return this.scheduleRelativeWithState(b,a,l)},n.start=function(){var a;if(!this.isEnabled){this.isEnabled=!0;do a=this.getNext(),null!==a?(this.comparer(a.dueTime,this.clock)>0&&(this.clock=a.dueTime),a.invoke()):this.isEnabled=!1;while(this.isEnabled)}},n.stop=function(){this.isEnabled=!1},n.advanceTo=function(a){var b,c=this.comparer(this.clock,a);if(this.comparer(this.clock,a)>0)throw new Error(argumentOutOfRange);if(0!==c&&!this.isEnabled){this.isEnabled=!0;do b=this.getNext(),null!==b&&this.comparer(b.dueTime,a)<=0?(this.comparer(b.dueTime,this.clock)>0&&(this.clock=b.dueTime),b.invoke()):this.isEnabled=!1;while(this.isEnabled);this.clock=a}},n.advanceBy=function(a){var b=this.add(this.clock,a),c=this.comparer(this.clock,b);if(c>0)throw new Error(argumentOutOfRange);0!==c&&this.advanceTo(b)},n.sleep=function(a){var b=this.add(this.clock,a);if(this.comparer(this.clock,b)>=0)throw new Error(argumentOutOfRange);this.clock=b},n.getNext=function(){for(var a;this.queue.length>0;){if(a=this.queue.peek(),!a.isCancelled())return a;this.queue.dequeue()}return null},n.scheduleAbsolute=function(a,b){return this.scheduleAbsoluteWithState(b,a,l)},n.scheduleAbsoluteWithState=function(a,b,c){var d=this,e=function(a,b){return d.queue.remove(f),c(a,b)},f=new g(d,a,e,b,d.comparer);return d.queue.enqueue(f),f.disposable},m}(e),c.HistoricalScheduler=function(a){function b(b,c){var e=null==b?0:b,f=c||d;a.call(this,e,f)}j(b,a);var c=b.prototype;return c.add=function(a,b){return a+b},c.toDateTimeOffset=function(a){return new Date(a).getTime()},c.toRelative=function(a){return a},b}(c.VirtualTimeScheduler),c});
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rxjs-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jdeseno
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
- - <
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.0'
|
30
|
+
- - <
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
33
|
+
description: This gem makes the RxJS js files available to the rails asset pipeline
|
34
|
+
email:
|
35
|
+
- jdeseno@gmail.com
|
36
|
+
executables: []
|
37
|
+
extensions: []
|
38
|
+
extra_rdoc_files: []
|
39
|
+
files:
|
40
|
+
- Gemfile
|
41
|
+
- LICENSE
|
42
|
+
- README.md
|
43
|
+
- lib/rxjs.rb
|
44
|
+
- lib/rxjs/rails.rb
|
45
|
+
- lib/rxjs/rails/engine.rb
|
46
|
+
- lib/rxjs/rails/railtie.rb
|
47
|
+
- lib/rxjs/rails/version.rb
|
48
|
+
- rxjs-rails.gemspec
|
49
|
+
- vendor/assets/javascripts/rx.aggregates.js
|
50
|
+
- vendor/assets/javascripts/rx.aggregates.min.js
|
51
|
+
- vendor/assets/javascripts/rx.async.compat.js
|
52
|
+
- vendor/assets/javascripts/rx.async.compat.min.js
|
53
|
+
- vendor/assets/javascripts/rx.async.js
|
54
|
+
- vendor/assets/javascripts/rx.async.min.js
|
55
|
+
- vendor/assets/javascripts/rx.binding.js
|
56
|
+
- vendor/assets/javascripts/rx.binding.min.js
|
57
|
+
- vendor/assets/javascripts/rx.coincidence.js
|
58
|
+
- vendor/assets/javascripts/rx.coincidence.min.js
|
59
|
+
- vendor/assets/javascripts/rx.compat.js
|
60
|
+
- vendor/assets/javascripts/rx.compat.min.js
|
61
|
+
- vendor/assets/javascripts/rx.experimental.js
|
62
|
+
- vendor/assets/javascripts/rx.experimental.min.js
|
63
|
+
- vendor/assets/javascripts/rx.joinpatterns.js
|
64
|
+
- vendor/assets/javascripts/rx.joinpatterns.min.js
|
65
|
+
- vendor/assets/javascripts/rx.lite.compat.js
|
66
|
+
- vendor/assets/javascripts/rx.lite.compat.min.js
|
67
|
+
- vendor/assets/javascripts/rx.lite.js
|
68
|
+
- vendor/assets/javascripts/rx.lite.min.js
|
69
|
+
- vendor/assets/javascripts/rx.min.js
|
70
|
+
- vendor/assets/javascripts/rx.node.js
|
71
|
+
- vendor/assets/javascripts/rx.testing.js
|
72
|
+
- vendor/assets/javascripts/rx.testing.min.js
|
73
|
+
- vendor/assets/javascripts/rx.time.js
|
74
|
+
- vendor/assets/javascripts/rx.time.min.js
|
75
|
+
- vendor/assets/javascripts/rx.virtualtime.js
|
76
|
+
- vendor/assets/javascripts/rx.virtualtime.min.js
|
77
|
+
homepage: http://rubygems.org/gems/rxjs-rails
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 1.3.6
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project: rxjs-rails
|
97
|
+
rubygems_version: 2.0.2
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: Use RxJS with rails
|
101
|
+
test_files: []
|