rxjs-rails 2.2.19 → 2.2.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -2
- data/lib/rxjs/rails/version.rb +1 -1
- data/vendor/assets/javascripts/rx.aggregates.js +126 -121
- data/vendor/assets/javascripts/rx.aggregates.min.js +1 -1
- data/vendor/assets/javascripts/rx.async.compat.js +2 -1
- data/vendor/assets/javascripts/rx.async.compat.min.js +1 -1
- data/vendor/assets/javascripts/rx.async.js +2 -1
- data/vendor/assets/javascripts/rx.async.min.js +1 -1
- data/vendor/assets/javascripts/rx.compat.js +470 -464
- data/vendor/assets/javascripts/rx.compat.min.js +2 -2
- data/vendor/assets/javascripts/rx.experimental.js +202 -191
- data/vendor/assets/javascripts/rx.experimental.min.js +1 -1
- data/vendor/assets/javascripts/rx.js +470 -464
- data/vendor/assets/javascripts/rx.lite.compat.js +352 -348
- data/vendor/assets/javascripts/rx.lite.compat.min.js +2 -2
- data/vendor/assets/javascripts/rx.lite.js +352 -348
- 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 +113 -115
- data/version.rb.m4 +6 -0
- metadata +3 -2
@@ -37,7 +37,7 @@
|
|
37
37
|
defaultSubComparer = Rx.helpers.defaultSubComparer = function (x, y) { return x > y ? 1 : (x < y ? -1 : 0); },
|
38
38
|
defaultKeySerializer = Rx.helpers.defaultKeySerializer = function (x) { return x.toString(); },
|
39
39
|
defaultError = Rx.helpers.defaultError = function (err) { throw err; },
|
40
|
-
isPromise = Rx.helpers.isPromise = function (p) { return typeof p.then === 'function' && p.then !== Rx.Observable.prototype.then; },
|
40
|
+
isPromise = Rx.helpers.isPromise = function (p) { return !!p && typeof p.then === 'function' && p.then !== Rx.Observable.prototype.then; },
|
41
41
|
asArray = Rx.helpers.asArray = function () { return Array.prototype.slice.call(arguments); },
|
42
42
|
not = Rx.helpers.not = function (a) { return !a; };
|
43
43
|
|
@@ -1032,25 +1032,25 @@
|
|
1032
1032
|
|
1033
1033
|
var normalizeTime = Scheduler.normalize;
|
1034
1034
|
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1035
|
+
/**
|
1036
|
+
* Gets a scheduler that schedules work immediately on the current thread.
|
1037
|
+
*/
|
1038
|
+
var immediateScheduler = Scheduler.immediate = (function () {
|
1039
1039
|
|
1040
|
-
|
1040
|
+
function scheduleNow(state, action) { return action(this, state); }
|
1041
1041
|
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1042
|
+
function scheduleRelative(state, dueTime, action) {
|
1043
|
+
var dt = normalizeTime(dt);
|
1044
|
+
while (dt - this.now() > 0) { }
|
1045
|
+
return action(this, state);
|
1046
|
+
}
|
1047
1047
|
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1048
|
+
function scheduleAbsolute(state, dueTime, action) {
|
1049
|
+
return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);
|
1050
|
+
}
|
1051
1051
|
|
1052
|
-
|
1053
|
-
|
1052
|
+
return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
|
1053
|
+
}());
|
1054
1054
|
|
1055
1055
|
/**
|
1056
1056
|
* Gets a scheduler that schedules work as soon as possible on the current thread.
|
@@ -1143,143 +1143,143 @@
|
|
1143
1143
|
return SchedulePeriodicRecursive;
|
1144
1144
|
}());
|
1145
1145
|
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
var reNative = RegExp('^' +
|
1151
|
-
String(toString)
|
1152
|
-
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
1153
|
-
.replace(/toString| for [^\]]+/g, '.*?') + '$'
|
1154
|
-
);
|
1155
|
-
|
1156
|
-
var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' &&
|
1157
|
-
!reNative.test(setImmediate) && setImmediate,
|
1158
|
-
clearImmediate = typeof (clearImmediate = freeGlobal && moduleExports && freeGlobal.clearImmediate) == 'function' &&
|
1159
|
-
!reNative.test(clearImmediate) && clearImmediate;
|
1160
|
-
|
1161
|
-
function postMessageSupported () {
|
1162
|
-
// Ensure not in a worker
|
1163
|
-
if (!root.postMessage || root.importScripts) { return false; }
|
1164
|
-
var isAsync = false,
|
1165
|
-
oldHandler = root.onmessage;
|
1166
|
-
// Test for async
|
1167
|
-
root.onmessage = function () { isAsync = true; };
|
1168
|
-
root.postMessage('','*');
|
1169
|
-
root.onmessage = oldHandler;
|
1170
|
-
|
1171
|
-
return isAsync;
|
1172
|
-
}
|
1146
|
+
|
1147
|
+
var scheduleMethod, clearMethod = noop;
|
1148
|
+
(function () {
|
1173
1149
|
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1150
|
+
var reNative = RegExp('^' +
|
1151
|
+
String(toString)
|
1152
|
+
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
1153
|
+
.replace(/toString| for [^\]]+/g, '.*?') + '$'
|
1154
|
+
);
|
1155
|
+
|
1156
|
+
var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' &&
|
1157
|
+
!reNative.test(setImmediate) && setImmediate,
|
1158
|
+
clearImmediate = typeof (clearImmediate = freeGlobal && moduleExports && freeGlobal.clearImmediate) == 'function' &&
|
1159
|
+
!reNative.test(clearImmediate) && clearImmediate;
|
1160
|
+
|
1161
|
+
function postMessageSupported () {
|
1162
|
+
// Ensure not in a worker
|
1163
|
+
if (!root.postMessage || root.importScripts) { return false; }
|
1164
|
+
var isAsync = false,
|
1165
|
+
oldHandler = root.onmessage;
|
1166
|
+
// Test for async
|
1167
|
+
root.onmessage = function () { isAsync = true; };
|
1168
|
+
root.postMessage('','*');
|
1169
|
+
root.onmessage = oldHandler;
|
1170
|
+
|
1171
|
+
return isAsync;
|
1172
|
+
}
|
1194
1173
|
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1174
|
+
// Use in order, nextTick, setImmediate, postMessage, MessageChannel, script readystatechanged, setTimeout
|
1175
|
+
if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
|
1176
|
+
scheduleMethod = process.nextTick;
|
1177
|
+
} else if (typeof setImmediate === 'function') {
|
1178
|
+
scheduleMethod = setImmediate;
|
1179
|
+
clearMethod = clearImmediate;
|
1180
|
+
} else if (postMessageSupported()) {
|
1181
|
+
var MSG_PREFIX = 'ms.rx.schedule' + Math.random(),
|
1182
|
+
tasks = {},
|
1183
|
+
taskId = 0;
|
1184
|
+
|
1185
|
+
function onGlobalPostMessage(event) {
|
1186
|
+
// Only if we're a match to avoid any other global events
|
1187
|
+
if (typeof event.data === 'string' && event.data.substring(0, MSG_PREFIX.length) === MSG_PREFIX) {
|
1188
|
+
var handleId = event.data.substring(MSG_PREFIX.length),
|
1189
|
+
action = tasks[handleId];
|
1190
|
+
action();
|
1191
|
+
delete tasks[handleId];
|
1199
1192
|
}
|
1193
|
+
}
|
1200
1194
|
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
} else if (!!root.MessageChannel) {
|
1207
|
-
var channel = new root.MessageChannel(),
|
1208
|
-
channelTasks = {},
|
1209
|
-
channelTaskId = 0;
|
1210
|
-
|
1211
|
-
channel.port1.onmessage = function (event) {
|
1212
|
-
var id = event.data,
|
1213
|
-
action = channelTasks[id];
|
1214
|
-
action();
|
1215
|
-
delete channelTasks[id];
|
1216
|
-
};
|
1195
|
+
if (root.addEventListener) {
|
1196
|
+
root.addEventListener('message', onGlobalPostMessage, false);
|
1197
|
+
} else {
|
1198
|
+
root.attachEvent('onmessage', onGlobalPostMessage, false);
|
1199
|
+
}
|
1217
1200
|
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1201
|
+
scheduleMethod = function (action) {
|
1202
|
+
var currentId = taskId++;
|
1203
|
+
tasks[currentId] = action;
|
1204
|
+
root.postMessage(MSG_PREFIX + currentId, '*');
|
1205
|
+
};
|
1206
|
+
} else if (!!root.MessageChannel) {
|
1207
|
+
var channel = new root.MessageChannel(),
|
1208
|
+
channelTasks = {},
|
1209
|
+
channelTaskId = 0;
|
1210
|
+
|
1211
|
+
channel.port1.onmessage = function (event) {
|
1212
|
+
var id = event.data,
|
1213
|
+
action = channelTasks[id];
|
1214
|
+
action();
|
1215
|
+
delete channelTasks[id];
|
1216
|
+
};
|
1217
|
+
|
1218
|
+
scheduleMethod = function (action) {
|
1219
|
+
var id = channelTaskId++;
|
1220
|
+
channelTasks[id] = action;
|
1221
|
+
channel.port2.postMessage(id);
|
1222
|
+
};
|
1223
|
+
} else if ('document' in root && 'onreadystatechange' in root.document.createElement('script')) {
|
1224
|
+
|
1225
|
+
scheduleMethod = function (action) {
|
1226
|
+
var scriptElement = root.document.createElement('script');
|
1227
|
+
scriptElement.onreadystatechange = function () {
|
1228
|
+
action();
|
1229
|
+
scriptElement.onreadystatechange = null;
|
1230
|
+
scriptElement.parentNode.removeChild(scriptElement);
|
1231
|
+
scriptElement = null;
|
1232
|
+
};
|
1233
|
+
root.document.documentElement.appendChild(scriptElement);
|
1234
|
+
};
|
1241
1235
|
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1236
|
+
} else {
|
1237
|
+
scheduleMethod = function (action) { return setTimeout(action, 0); };
|
1238
|
+
clearMethod = clearTimeout;
|
1239
|
+
}
|
1240
|
+
}());
|
1246
1241
|
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1242
|
+
/**
|
1243
|
+
* Gets a scheduler that schedules work via a timed callback based upon platform.
|
1244
|
+
*/
|
1245
|
+
var timeoutScheduler = Scheduler.timeout = (function () {
|
1246
|
+
|
1247
|
+
function scheduleNow(state, action) {
|
1248
|
+
var scheduler = this,
|
1249
|
+
disposable = new SingleAssignmentDisposable();
|
1250
|
+
var id = scheduleMethod(function () {
|
1251
|
+
if (!disposable.isDisposed) {
|
1252
|
+
disposable.setDisposable(action(scheduler, state));
|
1253
|
+
}
|
1254
|
+
});
|
1255
|
+
return new CompositeDisposable(disposable, disposableCreate(function () {
|
1256
|
+
clearMethod(id);
|
1257
|
+
}));
|
1258
|
+
}
|
1259
1259
|
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
}
|
1266
|
-
var disposable = new SingleAssignmentDisposable();
|
1267
|
-
var id = setTimeout(function () {
|
1268
|
-
if (!disposable.isDisposed) {
|
1269
|
-
disposable.setDisposable(action(scheduler, state));
|
1270
|
-
}
|
1271
|
-
}, dt);
|
1272
|
-
return new CompositeDisposable(disposable, disposableCreate(function () {
|
1273
|
-
clearTimeout(id);
|
1274
|
-
}));
|
1260
|
+
function scheduleRelative(state, dueTime, action) {
|
1261
|
+
var scheduler = this,
|
1262
|
+
dt = Scheduler.normalize(dueTime);
|
1263
|
+
if (dt === 0) {
|
1264
|
+
return scheduler.scheduleWithState(state, action);
|
1275
1265
|
}
|
1266
|
+
var disposable = new SingleAssignmentDisposable();
|
1267
|
+
var id = setTimeout(function () {
|
1268
|
+
if (!disposable.isDisposed) {
|
1269
|
+
disposable.setDisposable(action(scheduler, state));
|
1270
|
+
}
|
1271
|
+
}, dt);
|
1272
|
+
return new CompositeDisposable(disposable, disposableCreate(function () {
|
1273
|
+
clearTimeout(id);
|
1274
|
+
}));
|
1275
|
+
}
|
1276
1276
|
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1277
|
+
function scheduleAbsolute(state, dueTime, action) {
|
1278
|
+
return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);
|
1279
|
+
}
|
1280
1280
|
|
1281
|
-
|
1282
|
-
|
1281
|
+
return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
|
1282
|
+
})();
|
1283
1283
|
|
1284
1284
|
/**
|
1285
1285
|
* Represents a notification to an observer.
|
@@ -1903,28 +1903,26 @@
|
|
1903
1903
|
return new AnonymousObservable(subscribe);
|
1904
1904
|
};
|
1905
1905
|
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1926
|
-
});
|
1927
|
-
};
|
1906
|
+
/**
|
1907
|
+
* Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.
|
1908
|
+
*
|
1909
|
+
* @example
|
1910
|
+
* var res = Rx.Observable.defer(function () { return Rx.Observable.fromArray([1,2,3]); });
|
1911
|
+
* @param {Function} observableFactory Observable factory function to invoke for each observer that subscribes to the resulting sequence or Promise.
|
1912
|
+
* @returns {Observable} An observable sequence whose observers trigger an invocation of the given observable factory function.
|
1913
|
+
*/
|
1914
|
+
var observableDefer = Observable.defer = function (observableFactory) {
|
1915
|
+
return new AnonymousObservable(function (observer) {
|
1916
|
+
var result;
|
1917
|
+
try {
|
1918
|
+
result = observableFactory();
|
1919
|
+
} catch (e) {
|
1920
|
+
return observableThrow(e).subscribe(observer);
|
1921
|
+
}
|
1922
|
+
isPromise(result) && (result = observableFromPromise(result));
|
1923
|
+
return result.subscribe(observer);
|
1924
|
+
});
|
1925
|
+
};
|
1928
1926
|
|
1929
1927
|
/**
|
1930
1928
|
* Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.
|
@@ -2147,40 +2145,42 @@
|
|
2147
2145
|
});
|
2148
2146
|
};
|
2149
2147
|
|
2150
|
-
|
2151
|
-
|
2152
|
-
|
2153
|
-
|
2154
|
-
|
2155
|
-
|
2156
|
-
|
2157
|
-
|
2158
|
-
|
2159
|
-
|
2160
|
-
|
2161
|
-
}
|
2162
|
-
d = new SingleAssignmentDisposable();
|
2163
|
-
subscription.setDisposable(d);
|
2164
|
-
d.setDisposable(result.subscribe(observer));
|
2165
|
-
}, observer.onCompleted.bind(observer)));
|
2166
|
-
return subscription;
|
2167
|
-
});
|
2168
|
-
}
|
2169
|
-
|
2170
|
-
/**
|
2171
|
-
* Continues an observable sequence that is terminated by an exception with the next observable sequence.
|
2172
|
-
* @example
|
2173
|
-
* 1 - xs.catchException(ys)
|
2174
|
-
* 2 - xs.catchException(function (ex) { return ys(ex); })
|
2175
|
-
* @param {Mixed} handlerOrSecond Exception handler function that returns an observable sequence given the error that occurred in the first sequence, or a second observable sequence used to produce results when an error occurred in the first sequence.
|
2176
|
-
* @returns {Observable} An observable sequence containing the first sequence's elements, followed by the elements of the handler sequence in case an exception occurred.
|
2177
|
-
*/
|
2178
|
-
observableProto['catch'] = observableProto.catchException = function (handlerOrSecond) {
|
2179
|
-
if (typeof handlerOrSecond === 'function') {
|
2180
|
-
return observableCatchHandler(this, handlerOrSecond);
|
2148
|
+
function observableCatchHandler(source, handler) {
|
2149
|
+
return new AnonymousObservable(function (observer) {
|
2150
|
+
var d1 = new SingleAssignmentDisposable(), subscription = new SerialDisposable();
|
2151
|
+
subscription.setDisposable(d1);
|
2152
|
+
d1.setDisposable(source.subscribe(observer.onNext.bind(observer), function (exception) {
|
2153
|
+
var d, result;
|
2154
|
+
try {
|
2155
|
+
result = handler(exception);
|
2156
|
+
} catch (ex) {
|
2157
|
+
observer.onError(ex);
|
2158
|
+
return;
|
2181
2159
|
}
|
2182
|
-
|
2183
|
-
|
2160
|
+
isPromise(result) && (result = observableFromPromise(result));
|
2161
|
+
|
2162
|
+
d = new SingleAssignmentDisposable();
|
2163
|
+
subscription.setDisposable(d);
|
2164
|
+
d.setDisposable(result.subscribe(observer));
|
2165
|
+
}, observer.onCompleted.bind(observer)));
|
2166
|
+
|
2167
|
+
return subscription;
|
2168
|
+
});
|
2169
|
+
}
|
2170
|
+
|
2171
|
+
/**
|
2172
|
+
* Continues an observable sequence that is terminated by an exception with the next observable sequence.
|
2173
|
+
* @example
|
2174
|
+
* 1 - xs.catchException(ys)
|
2175
|
+
* 2 - xs.catchException(function (ex) { return ys(ex); })
|
2176
|
+
* @param {Mixed} handlerOrSecond Exception handler function that returns an observable sequence given the error that occurred in the first sequence, or a second observable sequence used to produce results when an error occurred in the first sequence.
|
2177
|
+
* @returns {Observable} An observable sequence containing the first sequence's elements, followed by the elements of the handler sequence in case an exception occurred.
|
2178
|
+
*/
|
2179
|
+
observableProto['catch'] = observableProto.catchException = function (handlerOrSecond) {
|
2180
|
+
return typeof handlerOrSecond === 'function' ?
|
2181
|
+
observableCatchHandler(this, handlerOrSecond) :
|
2182
|
+
observableCatch([this, handlerOrSecond]);
|
2183
|
+
};
|
2184
2184
|
|
2185
2185
|
/**
|
2186
2186
|
* Continues an observable sequence that is terminated by an exception with the next observable sequence.
|
@@ -2195,87 +2195,89 @@
|
|
2195
2195
|
return enumerableFor(items).catchException();
|
2196
2196
|
};
|
2197
2197
|
|
2198
|
-
|
2199
|
-
|
2200
|
-
|
2201
|
-
|
2202
|
-
|
2203
|
-
|
2204
|
-
|
2205
|
-
|
2206
|
-
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2213
|
-
|
2214
|
-
|
2215
|
-
|
2198
|
+
/**
|
2199
|
+
* Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
|
2200
|
+
* This can be in the form of an argument list of observables or an array.
|
2201
|
+
*
|
2202
|
+
* @example
|
2203
|
+
* 1 - obs = observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
|
2204
|
+
* 2 - obs = observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
|
2205
|
+
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
|
2206
|
+
*/
|
2207
|
+
observableProto.combineLatest = function () {
|
2208
|
+
var args = slice.call(arguments);
|
2209
|
+
if (Array.isArray(args[0])) {
|
2210
|
+
args[0].unshift(this);
|
2211
|
+
} else {
|
2212
|
+
args.unshift(this);
|
2213
|
+
}
|
2214
|
+
return combineLatest.apply(this, args);
|
2215
|
+
};
|
2216
2216
|
|
2217
|
-
|
2218
|
-
|
2219
|
-
|
2220
|
-
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
2224
|
-
|
2225
|
-
|
2226
|
-
|
2227
|
-
|
2228
|
-
|
2229
|
-
|
2230
|
-
|
2217
|
+
/**
|
2218
|
+
* Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.
|
2219
|
+
*
|
2220
|
+
* @example
|
2221
|
+
* 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
|
2222
|
+
* 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
|
2223
|
+
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
|
2224
|
+
*/
|
2225
|
+
var combineLatest = Observable.combineLatest = function () {
|
2226
|
+
var args = slice.call(arguments), resultSelector = args.pop();
|
2227
|
+
|
2228
|
+
if (Array.isArray(args[0])) {
|
2229
|
+
args = args[0];
|
2230
|
+
}
|
2231
2231
|
|
2232
|
-
|
2233
|
-
|
2234
|
-
|
2235
|
-
|
2236
|
-
|
2237
|
-
|
2238
|
-
|
2232
|
+
return new AnonymousObservable(function (observer) {
|
2233
|
+
var falseFactory = function () { return false; },
|
2234
|
+
n = args.length,
|
2235
|
+
hasValue = arrayInitialize(n, falseFactory),
|
2236
|
+
hasValueAll = false,
|
2237
|
+
isDone = arrayInitialize(n, falseFactory),
|
2238
|
+
values = new Array(n);
|
2239
2239
|
|
2240
|
-
|
2241
|
-
|
2242
|
-
|
2243
|
-
|
2244
|
-
|
2245
|
-
|
2246
|
-
|
2247
|
-
|
2248
|
-
|
2249
|
-
|
2250
|
-
|
2251
|
-
|
2252
|
-
|
2253
|
-
|
2254
|
-
|
2240
|
+
function next(i) {
|
2241
|
+
var res;
|
2242
|
+
hasValue[i] = true;
|
2243
|
+
if (hasValueAll || (hasValueAll = hasValue.every(identity))) {
|
2244
|
+
try {
|
2245
|
+
res = resultSelector.apply(null, values);
|
2246
|
+
} catch (ex) {
|
2247
|
+
observer.onError(ex);
|
2248
|
+
return;
|
2249
|
+
}
|
2250
|
+
observer.onNext(res);
|
2251
|
+
} else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {
|
2252
|
+
observer.onCompleted();
|
2253
|
+
}
|
2254
|
+
}
|
2255
2255
|
|
2256
|
-
|
2257
|
-
|
2258
|
-
|
2259
|
-
|
2260
|
-
|
2261
|
-
|
2256
|
+
function done (i) {
|
2257
|
+
isDone[i] = true;
|
2258
|
+
if (isDone.every(identity)) {
|
2259
|
+
observer.onCompleted();
|
2260
|
+
}
|
2261
|
+
}
|
2262
2262
|
|
2263
|
-
|
2264
|
-
|
2265
|
-
|
2266
|
-
|
2267
|
-
|
2268
|
-
|
2269
|
-
|
2270
|
-
|
2271
|
-
|
2272
|
-
|
2273
|
-
|
2274
|
-
|
2263
|
+
var subscriptions = new Array(n);
|
2264
|
+
for (var idx = 0; idx < n; idx++) {
|
2265
|
+
(function (i) {
|
2266
|
+
var source = args[i], sad = new SingleAssignmentDisposable();
|
2267
|
+
isPromise(source) && (source = observableFromPromise(source));
|
2268
|
+
sad.setDisposable(source.subscribe(function (x) {
|
2269
|
+
values[i] = x;
|
2270
|
+
next(i);
|
2271
|
+
}, observer.onError.bind(observer), function () {
|
2272
|
+
done(i);
|
2273
|
+
}));
|
2274
|
+
subscriptions[i] = sad;
|
2275
|
+
}(idx));
|
2276
|
+
}
|
2275
2277
|
|
2276
|
-
|
2277
|
-
|
2278
|
-
|
2278
|
+
return new CompositeDisposable(subscriptions);
|
2279
|
+
});
|
2280
|
+
};
|
2279
2281
|
|
2280
2282
|
/**
|
2281
2283
|
* Concatenates all the observable sequences. This takes in either an array or variable arguments to concatenate.
|
@@ -2528,86 +2530,88 @@
|
|
2528
2530
|
});
|
2529
2531
|
};
|
2530
2532
|
|
2531
|
-
|
2532
|
-
|
2533
|
-
|
2534
|
-
|
2535
|
-
|
2536
|
-
|
2537
|
-
|
2538
|
-
|
2539
|
-
|
2540
|
-
|
2541
|
-
|
2542
|
-
|
2543
|
-
|
2544
|
-
|
2545
|
-
|
2546
|
-
|
2547
|
-
|
2548
|
-
|
2549
|
-
|
2550
|
-
|
2533
|
+
function zipArray(second, resultSelector) {
|
2534
|
+
var first = this;
|
2535
|
+
return new AnonymousObservable(function (observer) {
|
2536
|
+
var index = 0, len = second.length;
|
2537
|
+
return first.subscribe(function (left) {
|
2538
|
+
if (index < len) {
|
2539
|
+
var right = second[index++], result;
|
2540
|
+
try {
|
2541
|
+
result = resultSelector(left, right);
|
2542
|
+
} catch (e) {
|
2543
|
+
observer.onError(e);
|
2544
|
+
return;
|
2545
|
+
}
|
2546
|
+
observer.onNext(result);
|
2547
|
+
} else {
|
2548
|
+
observer.onCompleted();
|
2549
|
+
}
|
2550
|
+
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
|
2551
|
+
});
|
2552
|
+
}
|
2551
2553
|
|
2552
|
-
|
2553
|
-
|
2554
|
-
|
2555
|
-
|
2556
|
-
|
2557
|
-
|
2558
|
-
|
2559
|
-
|
2560
|
-
|
2561
|
-
|
2562
|
-
|
2563
|
-
|
2554
|
+
/**
|
2555
|
+
* Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.
|
2556
|
+
* The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the sources.
|
2557
|
+
*
|
2558
|
+
* @example
|
2559
|
+
* 1 - res = obs1.zip(obs2, fn);
|
2560
|
+
* 1 - res = x1.zip([1,2,3], fn);
|
2561
|
+
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
|
2562
|
+
*/
|
2563
|
+
observableProto.zip = function () {
|
2564
|
+
if (Array.isArray(arguments[0])) {
|
2565
|
+
return zipArray.apply(this, arguments);
|
2566
|
+
}
|
2567
|
+
var parent = this, sources = slice.call(arguments), resultSelector = sources.pop();
|
2568
|
+
sources.unshift(parent);
|
2569
|
+
return new AnonymousObservable(function (observer) {
|
2570
|
+
var n = sources.length,
|
2571
|
+
queues = arrayInitialize(n, function () { return []; }),
|
2572
|
+
isDone = arrayInitialize(n, function () { return false; });
|
2573
|
+
|
2574
|
+
function next(i) {
|
2575
|
+
var res, queuedValues;
|
2576
|
+
if (queues.every(function (x) { return x.length > 0; })) {
|
2577
|
+
try {
|
2578
|
+
queuedValues = queues.map(function (x) { return x.shift(); });
|
2579
|
+
res = resultSelector.apply(parent, queuedValues);
|
2580
|
+
} catch (ex) {
|
2581
|
+
observer.onError(ex);
|
2582
|
+
return;
|
2583
|
+
}
|
2584
|
+
observer.onNext(res);
|
2585
|
+
} else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {
|
2586
|
+
observer.onCompleted();
|
2564
2587
|
}
|
2565
|
-
|
2566
|
-
sources.unshift(parent);
|
2567
|
-
return new AnonymousObservable(function (observer) {
|
2568
|
-
var n = sources.length,
|
2569
|
-
queues = arrayInitialize(n, function () { return []; }),
|
2570
|
-
isDone = arrayInitialize(n, function () { return false; });
|
2571
|
-
|
2572
|
-
var next = function (i) {
|
2573
|
-
var res, queuedValues;
|
2574
|
-
if (queues.every(function (x) { return x.length > 0; })) {
|
2575
|
-
try {
|
2576
|
-
queuedValues = queues.map(function (x) { return x.shift(); });
|
2577
|
-
res = resultSelector.apply(parent, queuedValues);
|
2578
|
-
} catch (ex) {
|
2579
|
-
observer.onError(ex);
|
2580
|
-
return;
|
2581
|
-
}
|
2582
|
-
observer.onNext(res);
|
2583
|
-
} else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {
|
2584
|
-
observer.onCompleted();
|
2585
|
-
}
|
2586
|
-
};
|
2588
|
+
};
|
2587
2589
|
|
2588
|
-
|
2589
|
-
|
2590
|
-
|
2591
|
-
|
2592
|
-
|
2593
|
-
|
2590
|
+
function done(i) {
|
2591
|
+
isDone[i] = true;
|
2592
|
+
if (isDone.every(function (x) { return x; })) {
|
2593
|
+
observer.onCompleted();
|
2594
|
+
}
|
2595
|
+
}
|
2594
2596
|
|
2595
|
-
|
2596
|
-
|
2597
|
-
|
2598
|
-
|
2599
|
-
|
2600
|
-
|
2601
|
-
|
2602
|
-
|
2603
|
-
|
2604
|
-
|
2605
|
-
|
2606
|
-
|
2597
|
+
var subscriptions = new Array(n);
|
2598
|
+
for (var idx = 0; idx < n; idx++) {
|
2599
|
+
(function (i) {
|
2600
|
+
var source = sources[i], sad = new SingleAssignmentDisposable();
|
2601
|
+
isPromise(source) && (source = observableFromPromise(source));
|
2602
|
+
sad.setDisposable(source.subscribe(function (x) {
|
2603
|
+
queues[i].push(x);
|
2604
|
+
next(i);
|
2605
|
+
}, observer.onError.bind(observer), function () {
|
2606
|
+
done(i);
|
2607
|
+
}));
|
2608
|
+
subscriptions[i] = sad;
|
2609
|
+
})(idx);
|
2610
|
+
}
|
2607
2611
|
|
2608
|
-
|
2609
|
-
|
2610
|
-
|
2612
|
+
return new CompositeDisposable(subscriptions);
|
2613
|
+
});
|
2614
|
+
};
|
2611
2615
|
/**
|
2612
2616
|
* Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
|
2613
2617
|
* @param arguments Observable sources.
|
@@ -3389,7 +3393,7 @@
|
|
3389
3393
|
selector);
|
3390
3394
|
}
|
3391
3395
|
if (jq) {
|
3392
|
-
var $elem = jq(
|
3396
|
+
var $elem = jq(element);
|
3393
3397
|
return fromEventPattern(
|
3394
3398
|
function (h) { $elem.on(eventName, h); },
|
3395
3399
|
function (h) { $elem.off(eventName, h); },
|