-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathoperation.event.ts
More file actions
43 lines (32 loc) · 949 Bytes
/
operation.event.ts
File metadata and controls
43 lines (32 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import {GenericEvent} from '@rxstack/async-event-dispatcher';
import {Request, Response} from '@rxstack/core';
import {Injector} from 'injection-js';
import {OperationMetadata} from '../metadata';
import * as _ from 'lodash';
import {OperationEventsEnum} from '../enums';
export class OperationEvent extends GenericEvent {
readonly metadata: OperationMetadata;
statusCode = 200;
eventType: OperationEventsEnum;
private _data: any;
private _response: Response;
constructor(public readonly request: Request,
public readonly injector: Injector,
metadata: OperationMetadata) {
super();
this.metadata = _.cloneDeep(metadata);
}
getData<T>(): T {
return this._data;
}
setData<T>(data: T): void {
this._data = data;
}
set response(response: Response) {
this._response = response;
this.stopPropagation();
}
get response(): Response {
return this._response;
}
}