node-eventstore-client/src/eventStoreSubscription.js

45 lines
1.0 KiB
JavaScript
Raw Normal View History

2016-03-09 20:46:15 +00:00
/***
* EventStoreSubscription
* @param {string} streamId
* @param {number} lastCommitPosition
* @param {?number} lastEventNumber
* @constructor
* @property {boolean} isSubscribedToAll
* @property {string} streamId
* @property {number} lastCommitPosition
* @property {?number} lastEventNumber
*/
function EventStoreSubscription(streamId, lastCommitPosition, lastEventNumber) {
Object.defineProperties(this, {
isSubscribedToAll: {
value: streamId === ''
},
streamId: {
value: streamId
},
lastCommitPosition: {
value: lastCommitPosition
},
lastEventNumber: {
value: lastEventNumber
}
});
}
/**
* Unsubscribes from the stream
*/
EventStoreSubscription.prototype.close = function() {
this.unsubscribe();
};
/**
* Unsubscribes from the stream
* @abstract
*/
EventStoreSubscription.prototype.unsubscribe = function() {
throw new Error("EventStoreSubscription.unsubscribe abstract method called." + this.constructor.name);
};
module.exports = EventStoreSubscription;