import * as plugins from './smartuniverse.plugins'; import { ReactionResponse } from './smartuniverse.classes.reactionresponse'; export class ReactionResult { private resultSubject = new plugins.smartrx.rxjs.Subject(); private endResult: Array = []; private completeDeferred = plugins.smartpromise.defer>(); constructor () { this.resultSubscribe(responseArg => { this.endResult.push(responseArg); }); } public resultSubscribe(observerArg: (responseArg: T['response']) => void) { return this.resultSubject.subscribe(observerArg); } public async getEndResult() { const result = await this.completeDeferred.promise; return result; } /** * push a reactionResponse */ public async pushReactionResponse(responseArg: T['response']) { this.resultSubject.next(responseArg); } /** * completes the ReactionResult */ public async complete() { this.completeDeferred.resolve(this.endResult); } }