smartuniverse/dist/smartuniverse.classes.universestore.js

34 lines
2.4 KiB
JavaScript
Raw Normal View History

2018-03-13 05:15:40 +00:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const smartuniverse_classes_universemessage_1 = require("./smartuniverse.classes.universemessage");
const lik_1 = require("lik");
const smartrx_1 = require("smartrx");
class UniverseStore {
constructor(standardMessageExpiryArg) {
this.destructionTime = 60000;
this.messageStore = new lik_1.Objectmap();
this.lastId = 0; // stores the last id
this.standardMessageExpiry = standardMessageExpiryArg;
}
/**
* add a message to the UniverseStore
* @param messageArg
* @param attachedPayloadArg
*/
addMessage(messageArg, attachedPayloadArg) {
this.messageStore.add(new smartuniverse_classes_universemessage_1.UniverseMessage(this, messageArg, attachedPayloadArg, this.destructionTime));
}
/**
* Read a message from the UniverseStore
*/
readMessagesYoungerThan(unixTimeArg) {
const messageObservable = smartrx_1.rxjs.Observable
.from(this.messageStore.getArray())
.filter(messageArg => {
return messageArg.timestamp.isYoungerThanMilliSeconds(this.destructionTime);
});
return messageObservable;
}
}
exports.UniverseStore = UniverseStore;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnR1bml2ZXJzZS5jbGFzc2VzLnVuaXZlcnNlc3RvcmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHVuaXZlcnNlLmNsYXNzZXMudW5pdmVyc2VzdG9yZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUVBLG1HQUEwRTtBQUUxRSw2QkFBK0I7QUFHL0IscUNBQThCO0FBRTlCO0lBTUUsWUFBWSx3QkFBZ0M7UUFKckMsb0JBQWUsR0FBVyxLQUFLLENBQUM7UUFDaEMsaUJBQVksR0FBRyxJQUFJLGVBQVMsRUFBbUIsQ0FBQztRQUMvQyxXQUFNLEdBQVcsQ0FBQyxDQUFDLENBQUMscUJBQXFCO1FBRy9DLElBQUksQ0FBQyxxQkFBcUIsR0F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