@artstesh/postboy 2.1.5 → 2.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +81 -27
  2. package/lib/i-postboy-depending.service.d.ts +3 -3
  3. package/lib/i-postboy-depending.service.js +2 -2
  4. package/lib/index.d.ts +10 -10
  5. package/lib/index.js +29 -29
  6. package/lib/locker.store.d.ts +8 -8
  7. package/lib/locker.store.js +26 -26
  8. package/lib/mocks/message-history-item-mock.d.ts +9 -9
  9. package/lib/mocks/message-history-item-mock.js +25 -25
  10. package/lib/mocks/message-history-mock.d.ts +8 -8
  11. package/lib/mocks/message-history-mock.js +23 -23
  12. package/lib/mocks/postboy-service-mock.d.ts +21 -21
  13. package/lib/mocks/postboy-service-mock.js +50 -50
  14. package/lib/models/message-queue.model.d.ts +43 -43
  15. package/lib/models/message-queue.model.js +65 -65
  16. package/lib/models/postboy-callback.message.d.ts +8 -8
  17. package/lib/models/postboy-callback.message.js +18 -18
  18. package/lib/models/postboy-execution.handler.d.ts +14 -14
  19. package/lib/models/postboy-execution.handler.js +16 -16
  20. package/lib/models/postboy-executor.d.ts +3 -3
  21. package/lib/models/postboy-executor.js +7 -7
  22. package/lib/models/postboy-generic-message.d.ts +7 -7
  23. package/lib/models/postboy-generic-message.js +18 -18
  24. package/lib/models/postboy-subscription.d.ts +6 -6
  25. package/lib/models/postboy-subscription.js +10 -10
  26. package/lib/models/postboy.locker.d.ts +5 -5
  27. package/lib/models/postboy.locker.js +2 -2
  28. package/lib/postboy-abstract.registrator.d.ts +113 -113
  29. package/lib/postboy-abstract.registrator.d.ts.map +1 -1
  30. package/lib/postboy-abstract.registrator.js +141 -141
  31. package/lib/postboy.service.d.ts +105 -105
  32. package/lib/postboy.service.js +160 -160
  33. package/lib/postboy.service.js.map +1 -1
  34. package/package.json +1 -1
@@ -1,114 +1,114 @@
1
- import { PostboyService } from './postboy.service';
2
- import { Observable, Subject } from 'rxjs';
3
- import { IPostboyDependingService } from './i-postboy-depending.service';
4
- import { PostboyExecutor } from './models/postboy-executor';
5
- import { PostboyGenericMessage } from './models/postboy-generic-message';
6
- import { PostboyExecutionHandler } from './models/postboy-execution.handler';
7
- export type MessageType<T extends PostboyGenericMessage> = new (...args: any[]) => T;
8
- export declare abstract class PostboyAbstractRegistrator {
9
- protected postboy: PostboyService;
10
- private ids;
11
- private services;
12
- constructor(postboy: PostboyService);
13
- /**
14
- * Registers a list of services to be used by the application.
15
- *
16
- * @param {IPostboyDependingService[]} services - An array of services to register.
17
- * @return {void} This method does not return a value.
18
- */
19
- registerServices(services: IPostboyDependingService[]): void;
20
- up(): void;
21
- protected abstract _up(): void;
22
- /**
23
- * @deprecated The method should be replaced with recordExecutor<T>
24
- */
25
- registerExecutor<E extends PostboyExecutor<T>, T>(id: string, exec: (e: E) => T): void;
26
- /**
27
- * @deprecated The method should be replaced with record<T>
28
- */
29
- register<T>(id: string, sub: Subject<T>): void;
30
- /**
31
- * @deprecated The method should be replaced with recordWithPipe<T>
32
- */
33
- registerWithPipe<T>(id: string, sub: Subject<T>, pipe: (s: Subject<T>) => Observable<T>): void;
34
- /**
35
- * @deprecated The method should be replaced with recordReplay<T>
36
- */
37
- registerReplay: <T>(id: string, bufferSize?: number) => void;
38
- /**
39
- * @deprecated The method should be replaced with recordBehavior<T>
40
- */
41
- registerBehavior: <T>(id: string, initial: T) => void;
42
- /**
43
- * @deprecated The method should be replaced with recordSubject<T>
44
- */
45
- registerSubject: <T>(id: string) => void;
46
- down(): void;
47
- /**
48
- * Records a type and its corresponding Subject<T> into the Postboy system and updates the internal identifiers.
49
- *
50
- * @param {MessageType<T>} type - A constructor for the generic message type T.
51
- * @param {Subject<T>} sub - The subject associated with the generic message type.
52
- * @return {this} Returns the current instance for method chaining.
53
- */
54
- record<T extends PostboyGenericMessage>(type: MessageType<T>, sub: Subject<T>): this;
55
- /**
56
- * Records a message type with a specific subject and applies a transformation pipe to the subject.
57
- *
58
- * @param {MessageType<T>} type - The constructor of the message type to record, which extends PostboyGenericMessage.
59
- * @param {Subject<T>} sub - The Subject instance to associate with the message type.
60
- * @param {(s: Subject<T>) => Observable<T>} pipe - A function that takes the subject as input and returns an Observable with transformations applied.
61
- * @return {this} The current instance of the class for chaining.
62
- */
63
- recordWithPipe<T extends PostboyGenericMessage>(type: MessageType<T>, sub: Subject<T>, pipe: (s: Subject<T>) => Observable<T>): this;
64
- /**
65
- * Records an executor associated with a specific type and execution logic.
66
- *
67
- * @param type The class constructor of the executor type to be recorded, which extends PostboyExecutor.
68
- * @param exec A callback function that executes the logic using an instance of the specified executor type.
69
- * @return void
70
- */
71
- recordExecutor<E extends PostboyExecutor<T>, T>(type: new (...args: any[]) => E, exec: (e: E) => T): void;
72
- /**
73
- * Records a handler for a specific executor type.
74
- *
75
- * @param executor The constructor of the executor type, which extends `PostboyExecutor`.
76
- * @param handler The execution handler associated with the given executor type.
77
- * @return void
78
- */
79
- recordHandler<E extends PostboyExecutor<R>, R>(executor: new (...args: any[]) => E, handler: PostboyExecutionHandler<R, E>): void;
80
- /**
81
- * A utility function that facilitates the recording and replaying of messages
82
- * using a ReplaySubject. This function is designed to handle messages of a
83
- * specific type and allows specifying a buffer size to determine how many
84
- * of the most recent messages should be replayed.
85
- *
86
- * @template T Extends the PostboyGenericMessage type, representing the type of message
87
- * to be recorded and replayed.
88
- * @param {MessageType<T>} type The constructor of the message type to be recorded and replayed.
89
- * @param {number} [bufferSize=1] The number of recent messages to retain in the ReplaySubject's buffer.
90
- * Defaults to 1 if not specified.
91
- * @returns The result of invoking the `record` method with the given message type and configured ReplaySubject.
92
- */
93
- recordReplay: <T extends PostboyGenericMessage>(type: MessageType<T>, bufferSize?: number) => this;
94
- /**
95
- * Represents a method that records a specific behavior associated with a message type.
96
- * It creates a `BehaviorSubject` initialized with the provided initial message
97
- * and associates it with the given message type using the `record` method.
98
- *
99
- * @template T - A type parameter extending `PostboyGenericMessage` that defines the message structure.
100
- * @param {MessageType<T>} type - The constructor function of the message type to be recorded.
101
- * @param {T} initial - The initial value of the message that will be set in the `BehaviorSubject`.
102
- * @returns {void} - This function does not return a value; instead, it modifies the internal state.
103
- */
104
- recordBehavior: <T extends PostboyGenericMessage>(type: MessageType<T>, initial: T) => this;
105
- /**
106
- * A function that creates and returns a new generic message recorder for a specific message type.
107
- *
108
- * @template T - A type parameter extending from `PostboyGenericMessage`.
109
- * @param {MessageType<T>} type - The constructor for the message type being recorded.
110
- * @returns {Subject<T>} A new instance of `Subject<T>` bound to the specified message type.
111
- */
112
- recordSubject: <T extends PostboyGenericMessage>(type: MessageType<T>) => this;
113
- }
1
+ import { PostboyService } from './postboy.service';
2
+ import { Observable, Subject } from 'rxjs';
3
+ import { IPostboyDependingService } from './i-postboy-depending.service';
4
+ import { PostboyExecutor } from './models/postboy-executor';
5
+ import { PostboyGenericMessage } from './models/postboy-generic-message';
6
+ import { PostboyExecutionHandler } from './models/postboy-execution.handler';
7
+ export type MessageType<T extends PostboyGenericMessage> = new (...args: any[]) => T;
8
+ export declare abstract class PostboyAbstractRegistrator {
9
+ protected postboy: PostboyService;
10
+ private ids;
11
+ private services;
12
+ constructor(postboy: PostboyService);
13
+ /**
14
+ * Registers a list of services to be used by the application.
15
+ *
16
+ * @param {IPostboyDependingService[]} services - An array of services to register.
17
+ * @return {void} This method does not return a value.
18
+ */
19
+ registerServices(services: IPostboyDependingService[]): void;
20
+ up(): void;
21
+ protected abstract _up(): void;
22
+ /**
23
+ * @deprecated The method should be replaced with recordExecutor<T>
24
+ */
25
+ registerExecutor<E extends PostboyExecutor<T>, T>(id: string, exec: (e: E) => T): void;
26
+ /**
27
+ * @deprecated The method should be replaced with record<T>
28
+ */
29
+ register<T>(id: string, sub: Subject<T>): void;
30
+ /**
31
+ * @deprecated The method should be replaced with recordWithPipe<T>
32
+ */
33
+ registerWithPipe<T>(id: string, sub: Subject<T>, pipe: (s: Subject<T>) => Observable<T>): void;
34
+ /**
35
+ * @deprecated The method should be replaced with recordReplay<T>
36
+ */
37
+ registerReplay: <T>(id: string, bufferSize?: number) => void;
38
+ /**
39
+ * @deprecated The method should be replaced with recordBehavior<T>
40
+ */
41
+ registerBehavior: <T>(id: string, initial: T) => void;
42
+ /**
43
+ * @deprecated The method should be replaced with recordSubject<T>
44
+ */
45
+ registerSubject: <T>(id: string) => void;
46
+ down(): void;
47
+ /**
48
+ * Records a type and its corresponding Subject<T> into the Postboy system and updates the internal identifiers.
49
+ *
50
+ * @param {MessageType<T>} type - A constructor for the generic message type T.
51
+ * @param {Subject<T>} sub - The subject associated with the generic message type.
52
+ * @return {this} Returns the current instance for method chaining.
53
+ */
54
+ record<T extends PostboyGenericMessage>(type: MessageType<T>, sub: Subject<T>): this;
55
+ /**
56
+ * Records a message type with a specific subject and applies a transformation pipe to the subject.
57
+ *
58
+ * @param {MessageType<T>} type - The constructor of the message type to record, which extends PostboyGenericMessage.
59
+ * @param {Subject<T>} sub - The Subject instance to associate with the message type.
60
+ * @param {(s: Subject<T>) => Observable<T>} pipe - A function that takes the subject as input and returns an Observable with transformations applied.
61
+ * @return {this} The current instance of the class for chaining.
62
+ */
63
+ recordWithPipe<T extends PostboyGenericMessage>(type: MessageType<T>, sub: Subject<T>, pipe: (s: Subject<T>) => Observable<T>): this;
64
+ /**
65
+ * Records an executor associated with a specific type and execution logic.
66
+ *
67
+ * @param type The class constructor of the executor type to be recorded, which extends PostboyExecutor.
68
+ * @param exec A callback function that executes the logic using an instance of the specified executor type.
69
+ * @return void
70
+ */
71
+ recordExecutor<E extends PostboyExecutor<T>, T>(type: new (...args: any[]) => E, exec: (e: E) => T): void;
72
+ /**
73
+ * Records a handler for a specific executor type.
74
+ *
75
+ * @param executor The constructor of the executor type, which extends `PostboyExecutor`.
76
+ * @param handler The execution handler associated with the given executor type.
77
+ * @return void
78
+ */
79
+ recordHandler<E extends PostboyExecutor<R>, R>(executor: new (...args: any[]) => E, handler: PostboyExecutionHandler<R, E>): void;
80
+ /**
81
+ * A utility function that facilitates the recording and replaying of messages
82
+ * using a ReplaySubject. This function is designed to handle messages of a
83
+ * specific type and allows specifying a buffer size to determine how many
84
+ * of the most recent messages should be replayed.
85
+ *
86
+ * @template T Extends the PostboyGenericMessage type, representing the type of message
87
+ * to be recorded and replayed.
88
+ * @param {MessageType<T>} type The constructor of the message type to be recorded and replayed.
89
+ * @param {number} [bufferSize=1] The number of recent messages to retain in the ReplaySubject's buffer.
90
+ * Defaults to 1 if not specified.
91
+ * @returns The result of invoking the `record` method with the given message type and configured ReplaySubject.
92
+ */
93
+ recordReplay: <T extends PostboyGenericMessage>(type: MessageType<T>, bufferSize?: number) => this;
94
+ /**
95
+ * Represents a method that records a specific behavior associated with a message type.
96
+ * It creates a `BehaviorSubject` initialized with the provided initial message
97
+ * and associates it with the given message type using the `record` method.
98
+ *
99
+ * @template T - A type parameter extending `PostboyGenericMessage` that defines the message structure.
100
+ * @param {MessageType<T>} type - The constructor function of the message type to be recorded.
101
+ * @param {T} initial - The initial value of the message that will be set in the `BehaviorSubject`.
102
+ * @returns {void} - This function does not return a value; instead, it modifies the internal state.
103
+ */
104
+ recordBehavior: <T extends PostboyGenericMessage>(type: MessageType<T>, initial: T) => this;
105
+ /**
106
+ * A function that creates and returns a new generic message recorder for a specific message type.
107
+ *
108
+ * @template T - A type parameter extending from `PostboyGenericMessage`.
109
+ * @param {MessageType<T>} type - The constructor for the message type being recorded.
110
+ * @returns {Subject<T>} A new instance of `Subject<T>` bound to the specified message type.
111
+ */
112
+ recordSubject: <T extends PostboyGenericMessage>(type: MessageType<T>) => this;
113
+ }
114
114
  //# sourceMappingURL=postboy-abstract.registrator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"postboy-abstract.registrator.d.ts","sourceRoot":"","sources":["../src/postboy-abstract.registrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAmB,UAAU,EAAiB,OAAO,EAAE,MAAM,MAAM,CAAC;AAC3E,O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AAW,MAAM,+BAAyE;IAE/G;;OAEG;IACI,gBAAgB,UAAW,MAAM,sBAAoE;IAE5G;;OAEG;IACI,eAAe,UAAW,MAAM,UAAyC;IAEzE,IAAI,IAAI,IAAI;IAOnB;;;;;;OAMG;IACI,MAAM,CAAC,CAAC,SAAS,qBAAqB,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI;IAM3F;;;;;;;OAOG;IACI,cAAc,CAAC,CAAC,SAAS,qBAAqB,EACnD,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EACpB,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,EACf,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,GACrC,IAAI;IAMP;;;;;;OAMG;IACI,cAAc,CAAC,CAAC,SAAS,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI;IAIhH;;;;;;OAMG;IACI,aAAa,CAAC,CAAC,SAAS,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,EAClD,QAAQ,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EACnC,OAAO,EAAE,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,GACrC,IAAI;IAIP;;;;;;;;;;;;OAYG;IACI,YAAY,uFACmC;IAEtD;;;;;;;;;OASG;IACI,cAAc,8EACgC;IAErD;;;;;;OAMG;IACI,aAAa,kEAAkG;CACvH"}
@@ -1,142 +1,142 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PostboyAbstractRegistrator = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const postboy_generic_message_1 = require("./models/postboy-generic-message");
6
- class PostboyAbstractRegistrator {
7
- constructor(postboy) {
8
- this.postboy = postboy;
9
- this.ids = [];
10
- this.services = [];
11
- /**
12
- * @deprecated The method should be replaced with recordReplay<T>
13
- */
14
- this.registerReplay = (id, bufferSize = 1) => this.register(id, new rxjs_1.ReplaySubject(bufferSize));
15
- /**
16
- * @deprecated The method should be replaced with recordBehavior<T>
17
- */
18
- this.registerBehavior = (id, initial) => this.register(id, new rxjs_1.BehaviorSubject(initial));
19
- /**
20
- * @deprecated The method should be replaced with recordSubject<T>
21
- */
22
- this.registerSubject = (id) => this.register(id, new rxjs_1.Subject());
23
- /**
24
- * A utility function that facilitates the recording and replaying of messages
25
- * using a ReplaySubject. This function is designed to handle messages of a
26
- * specific type and allows specifying a buffer size to determine how many
27
- * of the most recent messages should be replayed.
28
- *
29
- * @template T Extends the PostboyGenericMessage type, representing the type of message
30
- * to be recorded and replayed.
31
- * @param {MessageType<T>} type The constructor of the message type to be recorded and replayed.
32
- * @param {number} [bufferSize=1] The number of recent messages to retain in the ReplaySubject's buffer.
33
- * Defaults to 1 if not specified.
34
- * @returns The result of invoking the `record` method with the given message type and configured ReplaySubject.
35
- */
36
- this.recordReplay = (type, bufferSize = 1) => this.record(type, new rxjs_1.ReplaySubject(bufferSize));
37
- /**
38
- * Represents a method that records a specific behavior associated with a message type.
39
- * It creates a `BehaviorSubject` initialized with the provided initial message
40
- * and associates it with the given message type using the `record` method.
41
- *
42
- * @template T - A type parameter extending `PostboyGenericMessage` that defines the message structure.
43
- * @param {MessageType<T>} type - The constructor function of the message type to be recorded.
44
- * @param {T} initial - The initial value of the message that will be set in the `BehaviorSubject`.
45
- * @returns {void} - This function does not return a value; instead, it modifies the internal state.
46
- */
47
- this.recordBehavior = (type, initial) => this.record(type, new rxjs_1.BehaviorSubject(initial));
48
- /**
49
- * A function that creates and returns a new generic message recorder for a specific message type.
50
- *
51
- * @template T - A type parameter extending from `PostboyGenericMessage`.
52
- * @param {MessageType<T>} type - The constructor for the message type being recorded.
53
- * @returns {Subject<T>} A new instance of `Subject<T>` bound to the specified message type.
54
- */
55
- this.recordSubject = (type) => this.record(type, new rxjs_1.Subject());
56
- }
57
- /**
58
- * Registers a list of services to be used by the application.
59
- *
60
- * @param {IPostboyDependingService[]} services - An array of services to register.
61
- * @return {void} This method does not return a value.
62
- */
63
- registerServices(services) {
64
- this.services = services;
65
- }
66
- up() {
67
- this._up();
68
- this.services.forEach((s) => s.up());
69
- }
70
- /**
71
- * @deprecated The method should be replaced with recordExecutor<T>
72
- */
73
- registerExecutor(id, exec) {
74
- this.postboy.registerExecutor(id, exec);
75
- }
76
- /**
77
- * @deprecated The method should be replaced with record<T>
78
- */
79
- register(id, sub) {
80
- this.ids.push(id);
81
- this.postboy.register(id, sub);
82
- }
83
- /**
84
- * @deprecated The method should be replaced with recordWithPipe<T>
85
- */
86
- registerWithPipe(id, sub, pipe) {
87
- this.ids.push(id);
88
- this.postboy.registerWithPipe(id, sub, pipe);
89
- }
90
- down() {
91
- this.services = [];
92
- this.ids.forEach((id) => this.postboy.unregister(id));
93
- }
94
- // future
95
- /**
96
- * Records a type and its corresponding Subject<T> into the Postboy system and updates the internal identifiers.
97
- *
98
- * @param {MessageType<T>} type - A constructor for the generic message type T.
99
- * @param {Subject<T>} sub - The subject associated with the generic message type.
100
- * @return {this} Returns the current instance for method chaining.
101
- */
102
- record(type, sub) {
103
- this.ids.push((0, postboy_generic_message_1.checkId)(type));
104
- this.postboy.record(type, sub);
105
- return this;
106
- }
107
- /**
108
- * Records a message type with a specific subject and applies a transformation pipe to the subject.
109
- *
110
- * @param {MessageType<T>} type - The constructor of the message type to record, which extends PostboyGenericMessage.
111
- * @param {Subject<T>} sub - The Subject instance to associate with the message type.
112
- * @param {(s: Subject<T>) => Observable<T>} pipe - A function that takes the subject as input and returns an Observable with transformations applied.
113
- * @return {this} The current instance of the class for chaining.
114
- */
115
- recordWithPipe(type, sub, pipe) {
116
- this.ids.push((0, postboy_generic_message_1.checkId)(type));
117
- this.postboy.recordWithPipe(type, sub, pipe);
118
- return this;
119
- }
120
- /**
121
- * Records an executor associated with a specific type and execution logic.
122
- *
123
- * @param type The class constructor of the executor type to be recorded, which extends PostboyExecutor.
124
- * @param exec A callback function that executes the logic using an instance of the specified executor type.
125
- * @return void
126
- */
127
- recordExecutor(type, exec) {
128
- this.postboy.recordExecutor(type, exec);
129
- }
130
- /**
131
- * Records a handler for a specific executor type.
132
- *
133
- * @param executor The constructor of the executor type, which extends `PostboyExecutor`.
134
- * @param handler The execution handler associated with the given executor type.
135
- * @return void
136
- */
137
- recordHandler(executor, handler) {
138
- this.postboy.recordHandler(executor, handler);
139
- }
140
- }
141
- exports.PostboyAbstractRegistrator = PostboyAbstractRegistrator;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PostboyAbstractRegistrator = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const postboy_generic_message_1 = require("./models/postboy-generic-message");
6
+ class PostboyAbstractRegistrator {
7
+ constructor(postboy) {
8
+ this.postboy = postboy;
9
+ this.ids = [];
10
+ this.services = [];
11
+ /**
12
+ * @deprecated The method should be replaced with recordReplay<T>
13
+ */
14
+ this.registerReplay = (id, bufferSize = 1) => this.register(id, new rxjs_1.ReplaySubject(bufferSize));
15
+ /**
16
+ * @deprecated The method should be replaced with recordBehavior<T>
17
+ */
18
+ this.registerBehavior = (id, initial) => this.register(id, new rxjs_1.BehaviorSubject(initial));
19
+ /**
20
+ * @deprecated The method should be replaced with recordSubject<T>
21
+ */
22
+ this.registerSubject = (id) => this.register(id, new rxjs_1.Subject());
23
+ /**
24
+ * A utility function that facilitates the recording and replaying of messages
25
+ * using a ReplaySubject. This function is designed to handle messages of a
26
+ * specific type and allows specifying a buffer size to determine how many
27
+ * of the most recent messages should be replayed.
28
+ *
29
+ * @template T Extends the PostboyGenericMessage type, representing the type of message
30
+ * to be recorded and replayed.
31
+ * @param {MessageType<T>} type The constructor of the message type to be recorded and replayed.
32
+ * @param {number} [bufferSize=1] The number of recent messages to retain in the ReplaySubject's buffer.
33
+ * Defaults to 1 if not specified.
34
+ * @returns The result of invoking the `record` method with the given message type and configured ReplaySubject.
35
+ */
36
+ this.recordReplay = (type, bufferSize = 1) => this.record(type, new rxjs_1.ReplaySubject(bufferSize));
37
+ /**
38
+ * Represents a method that records a specific behavior associated with a message type.
39
+ * It creates a `BehaviorSubject` initialized with the provided initial message
40
+ * and associates it with the given message type using the `record` method.
41
+ *
42
+ * @template T - A type parameter extending `PostboyGenericMessage` that defines the message structure.
43
+ * @param {MessageType<T>} type - The constructor function of the message type to be recorded.
44
+ * @param {T} initial - The initial value of the message that will be set in the `BehaviorSubject`.
45
+ * @returns {void} - This function does not return a value; instead, it modifies the internal state.
46
+ */
47
+ this.recordBehavior = (type, initial) => this.record(type, new rxjs_1.BehaviorSubject(initial));
48
+ /**
49
+ * A function that creates and returns a new generic message recorder for a specific message type.
50
+ *
51
+ * @template T - A type parameter extending from `PostboyGenericMessage`.
52
+ * @param {MessageType<T>} type - The constructor for the message type being recorded.
53
+ * @returns {Subject<T>} A new instance of `Subject<T>` bound to the specified message type.
54
+ */
55
+ this.recordSubject = (type) => this.record(type, new rxjs_1.Subject());
56
+ }
57
+ /**
58
+ * Registers a list of services to be used by the application.
59
+ *
60
+ * @param {IPostboyDependingService[]} services - An array of services to register.
61
+ * @return {void} This method does not return a value.
62
+ */
63
+ registerServices(services) {
64
+ this.services = services;
65
+ }
66
+ up() {
67
+ this._up();
68
+ this.services.forEach((s) => s.up());
69
+ }
70
+ /**
71
+ * @deprecated The method should be replaced with recordExecutor<T>
72
+ */
73
+ registerExecutor(id, exec) {
74
+ this.postboy.registerExecutor(id, exec);
75
+ }
76
+ /**
77
+ * @deprecated The method should be replaced with record<T>
78
+ */
79
+ register(id, sub) {
80
+ this.ids.push(id);
81
+ this.postboy.register(id, sub);
82
+ }
83
+ /**
84
+ * @deprecated The method should be replaced with recordWithPipe<T>
85
+ */
86
+ registerWithPipe(id, sub, pipe) {
87
+ this.ids.push(id);
88
+ this.postboy.registerWithPipe(id, sub, pipe);
89
+ }
90
+ down() {
91
+ this.services = [];
92
+ this.ids.forEach((id) => this.postboy.unregister(id));
93
+ }
94
+ // future
95
+ /**
96
+ * Records a type and its corresponding Subject<T> into the Postboy system and updates the internal identifiers.
97
+ *
98
+ * @param {MessageType<T>} type - A constructor for the generic message type T.
99
+ * @param {Subject<T>} sub - The subject associated with the generic message type.
100
+ * @return {this} Returns the current instance for method chaining.
101
+ */
102
+ record(type, sub) {
103
+ this.ids.push((0, postboy_generic_message_1.checkId)(type));
104
+ this.postboy.record(type, sub);
105
+ return this;
106
+ }
107
+ /**
108
+ * Records a message type with a specific subject and applies a transformation pipe to the subject.
109
+ *
110
+ * @param {MessageType<T>} type - The constructor of the message type to record, which extends PostboyGenericMessage.
111
+ * @param {Subject<T>} sub - The Subject instance to associate with the message type.
112
+ * @param {(s: Subject<T>) => Observable<T>} pipe - A function that takes the subject as input and returns an Observable with transformations applied.
113
+ * @return {this} The current instance of the class for chaining.
114
+ */
115
+ recordWithPipe(type, sub, pipe) {
116
+ this.ids.push((0, postboy_generic_message_1.checkId)(type));
117
+ this.postboy.recordWithPipe(type, sub, pipe);
118
+ return this;
119
+ }
120
+ /**
121
+ * Records an executor associated with a specific type and execution logic.
122
+ *
123
+ * @param type The class constructor of the executor type to be recorded, which extends PostboyExecutor.
124
+ * @param exec A callback function that executes the logic using an instance of the specified executor type.
125
+ * @return void
126
+ */
127
+ recordExecutor(type, exec) {
128
+ this.postboy.recordExecutor(type, exec);
129
+ }
130
+ /**
131
+ * Records a handler for a specific executor type.
132
+ *
133
+ * @param executor The constructor of the executor type, which extends `PostboyExecutor`.
134
+ * @param handler The execution handler associated with the given executor type.
135
+ * @return void
136
+ */
137
+ recordHandler(executor, handler) {
138
+ this.postboy.recordHandler(executor, handler);
139
+ }
140
+ }
141
+ exports.PostboyAbstractRegistrator = PostboyAbstractRegistrator;
142
142
  //# sourceMappingURL=postboy-abstract.registrator.js.map