This commit is contained in:
Nicolas Dextraze
2017-02-25 14:12:13 -08:00
parent 34e928c440
commit 158ca2d0a7
6 changed files with 2343 additions and 7 deletions

View File

@ -22,9 +22,10 @@ module.exports.isArrayOf = function(expectedType, value, name) {
throw new TypeError([name, " should be an array of ", expectedType.name, "."].join(""));
};
module.exports.isTypeOf = function(expectedType, value, name) {
module.exports.isTypeOf = function(expectedType, value, name, nullAllowed) {
if (nullAllowed && value === null) return;
if (!(value instanceof expectedType))
throw new TypeError([name, " should be of type '", expectedType.name, "'."].join(""));
throw new TypeError([name, " should be of type '", expectedType.name, "'", nullAllowed ? " or null": "", "."].join(""));
};
module.exports.positive = function(value, name) {

View File

@ -46,8 +46,6 @@ EventStoreAllCatchUpSubscription.prototype._readEventsTill = function(
var done = lastCommitPosition === null
? slice.isEndOfStream
: slice.nextPosition.compareTo(new results.Position(lastCommitPosition, lastCommitPosition)) >= 0;
if (!done && slice.isEndOfStream)
return Promise.resolve(done).delay(10);
return Promise.resolve(done);
});
})

View File

@ -492,7 +492,10 @@ EventStoreNodeConnection.prototype.subscribeToAllFrom = function(
lastCheckpoint, resolveLinkTos, eventAppeared, liveProcessingStarted, subscriptionDropped,
userCredentials, readBatchSize
) {
if (typeof eventAppeared !== 'function') throw new TypeError("eventAppeared must be a function.");
ensure.isTypeOf(results.Position, lastCheckpoint, "lastCheckpoint", true);
ensure.isTypeOf(Function, eventAppeared, "eventAppeared", false);
if (liveProcessingStarted) ensure.isTypeOf(Function, liveProcessingStarted, "liveProcessingStarted", false);
if (subscriptionDropped) ensure.isTypeOf(Function, subscriptionDropped, "subscriptionDropped", false);
var catchUpSubscription =
new EventStoreAllCatchUpSubscription(this, this._settings.log, lastCheckpoint, resolveLinkTos,