@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
package/README.md CHANGED
@@ -1,27 +1,81 @@
1
- # ArtsteshPostboy
2
-
3
- This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 12.2.18.
4
-
5
- ## Development server
6
-
7
- Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
8
-
9
- ## Code scaffolding
10
-
11
- Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
12
-
13
- ## Build
14
-
15
- Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
16
-
17
- ## Running unit tests
18
-
19
- Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20
-
21
- ## Running end-to-end tests
22
-
23
- Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
24
-
25
- ## Further help
26
-
27
- To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
1
+ The `@artstesh/postboy` library is designed to simplify the development of TypeScript applications using an event-driven approach. It provides convenient tools for working with the `rxjs` library, managing events, and handling dependencies, allowing developers to focus on business logic rather than boilerplate.
2
+
3
+ ## Purpose of the Library
4
+
5
+ In complex applications a developer always faces with a huge amount of services, subscriptions and, as a result, with a long list of dependencies in components of the system. Some services have to combine their own logic with providing of subscriptions, other exist only to define a list of observations to link components of the system. It is getting harder to support so many dependencies, testing becomes a nightmare add... to say the truth, it looks bad) Plus, it is neccessary to close all the subs properly to avoid memory leaks...
6
+
7
+ `@artstesh/postboy` is a tool aimed at reducing this complexity by removing repetitive tasks from development. It focuses on minimizing boilerplate code and eliminating issues such as subscription leaks and improper dependency handling.
8
+
9
+ ## Key Features
10
+
11
+ 1. **Event-Driven Architecture**
12
+ Enables creating event-based applications with minimal overhead and explicit subscription management. This is especially useful for large-scale applications where data delivery and reaction to events play a critical role.
13
+
14
+ 2. **Integration with `rxjs`**
15
+ Reactive programming is supported out of the box. This enables easy use of `rxjs` to process events.
16
+
17
+ 3. **Dependency Management**
18
+ The library simplifies dependency handling by providing an efficient mechanism for managing them.
19
+
20
+ 4. **Seamless Integration**
21
+ `@artstesh/postboy` can be easily integrated into existing TypeScript projects and helps structure applications into independent components with clear responsibilities for events and reactions.
22
+
23
+ 5. **Modularity and Scalability**
24
+ Thanks to its approach, the library is suitable for both small applications and large-scale projects with complex functionality.
25
+
26
+ ## Usage Example
27
+
28
+ Let’s take a look at a simple example to demonstrate how `@artstesh/postboy` can be used to handle events.
29
+
30
+ ### The case
31
+
32
+ Suppose we such a simple structure in an Angular application:
33
+
34
+ <img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2MDAiIGhlaWdodD0iNDAwIiBzdHlsZT0iYmFja2dyb3VuZC1jb2xvcjogdHJhbnNwYXJlbnQ7IGZvbnQtZmFtaWx5OiBBcmlhbCwgc2Fucy1zZXJpZjsgZm9udC1zaXplOiAxNHB4OyI+DQogIDwhLS0gRmlyc3QgTGV2ZWwgQ29tcG9uZW50IC0tPg0KICA8cmVjdCB4PSIyMzAiIHk9IjIwIiB3aWR0aD0iMTQwIiBoZWlnaHQ9IjUwIiBmaWxsPSIjYzhlNmM5IiBzdHJva2U9IiMyZTdkMzIiIHN0cm9rZS13aWR0aD0iMiIgcng9IjYiPjwvcmVjdD4NCiAgPHRleHQgeD0iMzAwIiB5PSI1MCIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZmlsbD0iIzJlN2QzMiI+QXBwQ29tcG9uZW50PC90ZXh0Pg0KDQogIDwhLS0gU2Vjb25kIExldmVsIENvbXBvbmVudHMgLS0+DQogIDxyZWN0IHg9IjEzMCIgeT0iMTIwIiB3aWR0aD0iMTQwIiBoZWlnaHQ9IjUwIiBmaWxsPSIjZmZlY2IzIiBzdHJva2U9IiNmNTdjMDAiIHN0cm9rZS13aWR0aD0iMiIgcng9IjYiPjwvcmVjdD4NCiAgPHRleHQgeD0iMjAwIiB5PSIxNTAiIHRleHQtYW5jaG9yPSJtaWRkbGUiIGZpbGw9IiNmNTd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b2x5Z29uIHBvaW50cz0iMCAwLCAxMCAzLjUsIDAgNyIgZmlsbD0iIzYwNjA2MCI+PC9wb2x5Z29uPg0KICAgIDwvbWFya2VyPg0KICA8L2RlZnM+DQo8L3N2Zz4NCg==">
35
+
36
+ **Child B** contains a text input and **Child A** have show the value of the input.
37
+
38
+ In a common case, we would create a specific service with an observable; but it alse means that we have to get an instance of the service in **Child A** and **Child B** and the service itself looks pretty bad - it is just a wrapper over the observable.
39
+
40
+ *I don't event want to describe the idea of sending information through the parents - it is much more painful and dirty.
41
+
42
+ ### The postboy approach
43
+
44
+ ```typescript
45
+ import {PostboyService} from '@artstesh/postboy';
46
+
47
+ public class ChildA {
48
+ constructor(private postboy: PostboyService) {
49
+ }
50
+
51
+ public ngOnInit(){
52
+ this.postboy.sub(UserInputEvent).subscribe(ev => {
53
+ console.log(ev.text);
54
+ })
55
+ }
56
+ }
57
+
58
+ public class ChildB {
59
+ constructor(private postboy: PostboyService) {
60
+ }
61
+
62
+ public onInput(){
63
+ this.postboy.fire(new UserInputEvent(this.text));
64
+ }
65
+ }
66
+ ```
67
+
68
+ ### Key Benefits of This Approach
69
+
70
+ - Clear separation of event generation and event handling.
71
+ - TypeScript interfaces ensure strict typing for the data passed between different parts of the application.
72
+ - The members of the system know nothing about each other
73
+ - No need to create specific mediators
74
+
75
+ ## Advantages of the Library
76
+
77
+ - **Simplicity:** Clear structure for managing events and their processing.
78
+ - **Safety:** TypeScript ensures type-safety, minimizing potential errors.
79
+ - **Flexibility:** `rxjs` integration allows advanced event processing, such as filtering, pre-processing, and combining event streams.
80
+ - **Scalability:** Code becomes clean and easy to extend without introducing unnecessary complexity.
81
+
@@ -1,4 +1,4 @@
1
- export interface IPostboyDependingService {
2
- up(): void;
3
- }
1
+ export interface IPostboyDependingService {
2
+ up(): void;
3
+ }
4
4
  //# sourceMappingURL=i-postboy-depending.service.d.ts.map
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=i-postboy-depending.service.js.map
package/lib/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- export * from './postboy.service';
2
- export * from './mocks/postboy-service-mock';
3
- export * from './i-postboy-depending.service';
4
- export * from './postboy-abstract.registrator';
5
- export * from './models/postboy-generic-message';
6
- export * from './models/postboy-callback.message';
7
- export * from './models/postboy.locker';
8
- export * from './models/postboy-execution.handler';
9
- export * from './models/postboy-executor';
10
- export * from './models/message-queue.model';
1
+ export * from './postboy.service';
2
+ export * from './mocks/postboy-service-mock';
3
+ export * from './i-postboy-depending.service';
4
+ export * from './postboy-abstract.registrator';
5
+ export * from './models/postboy-generic-message';
6
+ export * from './models/postboy-callback.message';
7
+ export * from './models/postboy.locker';
8
+ export * from './models/postboy-execution.handler';
9
+ export * from './models/postboy-executor';
10
+ export * from './models/message-queue.model';
11
11
  //# sourceMappingURL=index.d.ts.map
package/lib/index.js CHANGED
@@ -1,30 +1,30 @@
1
- "use strict";
2
- /*
3
- * Public API Surface of postboy
4
- */
5
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
- desc = { enumerable: true, get: function() { return m[k]; } };
10
- }
11
- Object.defineProperty(o, k2, desc);
12
- }) : (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- o[k2] = m[k];
15
- }));
16
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- __exportStar(require("./postboy.service"), exports);
21
- __exportStar(require("./mocks/postboy-service-mock"), exports);
22
- __exportStar(require("./i-postboy-depending.service"), exports);
23
- __exportStar(require("./postboy-abstract.registrator"), exports);
24
- __exportStar(require("./models/postboy-generic-message"), exports);
25
- __exportStar(require("./models/postboy-callback.message"), exports);
26
- __exportStar(require("./models/postboy.locker"), exports);
27
- __exportStar(require("./models/postboy-execution.handler"), exports);
28
- __exportStar(require("./models/postboy-executor"), exports);
29
- __exportStar(require("./models/message-queue.model"), exports);
1
+ "use strict";
2
+ /*
3
+ * Public API Surface of postboy
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./postboy.service"), exports);
21
+ __exportStar(require("./mocks/postboy-service-mock"), exports);
22
+ __exportStar(require("./i-postboy-depending.service"), exports);
23
+ __exportStar(require("./postboy-abstract.registrator"), exports);
24
+ __exportStar(require("./models/postboy-generic-message"), exports);
25
+ __exportStar(require("./models/postboy-callback.message"), exports);
26
+ __exportStar(require("./models/postboy.locker"), exports);
27
+ __exportStar(require("./models/postboy-execution.handler"), exports);
28
+ __exportStar(require("./models/postboy-executor"), exports);
29
+ __exportStar(require("./models/message-queue.model"), exports);
30
30
  //# sourceMappingURL=index.js.map
@@ -1,9 +1,9 @@
1
- import { PostboyLocker } from './models/postboy.locker';
2
- export declare class LockerStore {
3
- private lockers;
4
- private unlockers;
5
- private locked;
6
- addLocker(locker: PostboyLocker): void;
7
- check(eventId: string): boolean;
8
- }
1
+ import { PostboyLocker } from './models/postboy.locker';
2
+ export declare class LockerStore {
3
+ private lockers;
4
+ private unlockers;
5
+ private locked;
6
+ addLocker(locker: PostboyLocker): void;
7
+ check(eventId: string): boolean;
8
+ }
9
9
  //# sourceMappingURL=locker.store.d.ts.map
@@ -1,27 +1,27 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LockerStore = void 0;
4
- class LockerStore {
5
- constructor() {
6
- this.lockers = {};
7
- this.unlockers = {};
8
- this.locked = new Set();
9
- }
10
- addLocker(locker) {
11
- if (locker.locker)
12
- this.lockers[locker.locker] = locker.locking;
13
- if (locker.unlocker)
14
- this.unlockers[locker.unlocker] = locker.locking;
15
- }
16
- check(eventId) {
17
- if (this.locked.has(eventId))
18
- return false;
19
- if (this.unlockers[eventId])
20
- this.unlockers[eventId].forEach((id) => this.locked.delete(id));
21
- if (this.lockers[eventId])
22
- this.lockers[eventId].forEach((id) => this.locked.add(id));
23
- return true;
24
- }
25
- }
26
- exports.LockerStore = LockerStore;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LockerStore = void 0;
4
+ class LockerStore {
5
+ constructor() {
6
+ this.lockers = {};
7
+ this.unlockers = {};
8
+ this.locked = new Set();
9
+ }
10
+ addLocker(locker) {
11
+ if (locker.locker)
12
+ this.lockers[locker.locker] = locker.locking;
13
+ if (locker.unlocker)
14
+ this.unlockers[locker.unlocker] = locker.locking;
15
+ }
16
+ check(eventId) {
17
+ if (this.locked.has(eventId))
18
+ return false;
19
+ if (this.unlockers[eventId])
20
+ this.unlockers[eventId].forEach((id) => this.locked.delete(id));
21
+ if (this.lockers[eventId])
22
+ this.lockers[eventId].forEach((id) => this.locked.add(id));
23
+ return true;
24
+ }
25
+ }
26
+ exports.LockerStore = LockerStore;
27
27
  //# sourceMappingURL=locker.store.js.map
@@ -1,10 +1,10 @@
1
- import { PostboyGenericMessage } from '../models/postboy-generic-message';
2
- export declare class MessageHistoryItemMock<T extends PostboyGenericMessage> {
3
- private list;
4
- add(message: T): this;
5
- clear(): void;
6
- get length(): number;
7
- get last(): T;
8
- get all(): T[];
9
- }
1
+ import { PostboyGenericMessage } from '../models/postboy-generic-message';
2
+ export declare class MessageHistoryItemMock<T extends PostboyGenericMessage> {
3
+ private list;
4
+ add(message: T): this;
5
+ clear(): void;
6
+ get length(): number;
7
+ get last(): T;
8
+ get all(): T[];
9
+ }
10
10
  //# sourceMappingURL=message-history-item-mock.d.ts.map
@@ -1,26 +1,26 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessageHistoryItemMock = void 0;
4
- class MessageHistoryItemMock {
5
- constructor() {
6
- this.list = [];
7
- }
8
- add(message) {
9
- this.list.push(message);
10
- return this;
11
- }
12
- clear() {
13
- this.list = [];
14
- }
15
- get length() {
16
- return this.list.length;
17
- }
18
- get last() {
19
- return this.list[this.list.length - 1];
20
- }
21
- get all() {
22
- return [...this.list];
23
- }
24
- }
25
- exports.MessageHistoryItemMock = MessageHistoryItemMock;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessageHistoryItemMock = void 0;
4
+ class MessageHistoryItemMock {
5
+ constructor() {
6
+ this.list = [];
7
+ }
8
+ add(message) {
9
+ this.list.push(message);
10
+ return this;
11
+ }
12
+ clear() {
13
+ this.list = [];
14
+ }
15
+ get length() {
16
+ return this.list.length;
17
+ }
18
+ get last() {
19
+ return this.list[this.list.length - 1];
20
+ }
21
+ get all() {
22
+ return [...this.list];
23
+ }
24
+ }
25
+ exports.MessageHistoryItemMock = MessageHistoryItemMock;
26
26
  //# sourceMappingURL=message-history-item-mock.js.map
@@ -1,9 +1,9 @@
1
- import { PostboyGenericMessage } from '../models/postboy-generic-message';
2
- import { MessageHistoryItemMock } from './message-history-item-mock';
3
- export declare class MessageHistoryMock {
4
- private _items;
5
- get<T extends PostboyGenericMessage>(id: string): MessageHistoryItemMock<T>;
6
- add(message: PostboyGenericMessage): void;
7
- reset(): void;
8
- }
1
+ import { PostboyGenericMessage } from '../models/postboy-generic-message';
2
+ import { MessageHistoryItemMock } from './message-history-item-mock';
3
+ export declare class MessageHistoryMock {
4
+ private _items;
5
+ get<T extends PostboyGenericMessage>(id: string): MessageHistoryItemMock<T>;
6
+ add(message: PostboyGenericMessage): void;
7
+ reset(): void;
8
+ }
9
9
  //# sourceMappingURL=message-history-mock.d.ts.map
@@ -1,24 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessageHistoryMock = void 0;
4
- const message_history_item_mock_1 = require("./message-history-item-mock");
5
- const collections_1 = require("@artstesh/collections");
6
- class MessageHistoryMock {
7
- constructor() {
8
- this._items = new collections_1.Dictionary();
9
- }
10
- get(id) {
11
- var _a;
12
- return (_a = this._items.take(id)) !== null && _a !== void 0 ? _a : new message_history_item_mock_1.MessageHistoryItemMock();
13
- }
14
- add(message) {
15
- var _a;
16
- if (!((_a = this._items.take(message.id)) === null || _a === void 0 ? void 0 : _a.add(message)))
17
- this._items.put(message.id, new message_history_item_mock_1.MessageHistoryItemMock().add(message));
18
- }
19
- reset() {
20
- this._items.forEach((i) => i.clear());
21
- }
22
- }
23
- exports.MessageHistoryMock = MessageHistoryMock;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessageHistoryMock = void 0;
4
+ const message_history_item_mock_1 = require("./message-history-item-mock");
5
+ const collections_1 = require("@artstesh/collections");
6
+ class MessageHistoryMock {
7
+ constructor() {
8
+ this._items = new collections_1.Dictionary();
9
+ }
10
+ get(id) {
11
+ var _a;
12
+ return (_a = this._items.take(id)) !== null && _a !== void 0 ? _a : new message_history_item_mock_1.MessageHistoryItemMock();
13
+ }
14
+ add(message) {
15
+ var _a;
16
+ if (!((_a = this._items.take(message.id)) === null || _a === void 0 ? void 0 : _a.add(message)))
17
+ this._items.put(message.id, new message_history_item_mock_1.MessageHistoryItemMock().add(message));
18
+ }
19
+ reset() {
20
+ this._items.forEach((i) => i.clear());
21
+ }
22
+ }
23
+ exports.MessageHistoryMock = MessageHistoryMock;
24
24
  //# sourceMappingURL=message-history-mock.js.map
@@ -1,22 +1,22 @@
1
- import { PostboyService } from '../postboy.service';
2
- import { Observable } from 'rxjs';
3
- import { PostboyExecutor } from '../models/postboy-executor';
4
- import { PostboyGenericMessage } from '../models/postboy-generic-message';
5
- import { PostboyCallbackMessage } from '../models/postboy-callback.message';
6
- import { MessageHistoryItemMock } from './message-history-item-mock';
7
- import { MessageType } from '../postboy-abstract.registrator';
8
- export declare class PostboyServiceMock extends PostboyService {
9
- private subscriptions;
10
- private _history;
11
- reset(): void;
12
- fired(id: string, times?: number): boolean;
13
- subscribed(id: string, times?: number): boolean;
14
- private count;
15
- exec<E extends PostboyExecutor<T>, T>(executor: E): T;
16
- subscribe<T>(id: string): Observable<T>;
17
- sub<T extends PostboyGenericMessage>(type: MessageType<T>): Observable<T>;
18
- fire<T extends PostboyGenericMessage>(message: T): void;
19
- fireCallback<T>(message: PostboyCallbackMessage<T>, action?: (e: T) => void): void;
20
- history<T extends PostboyGenericMessage>(type: MessageType<T>): MessageHistoryItemMock<T>;
21
- }
1
+ import { PostboyService } from '../postboy.service';
2
+ import { Observable } from 'rxjs';
3
+ import { PostboyExecutor } from '../models/postboy-executor';
4
+ import { PostboyGenericMessage } from '../models/postboy-generic-message';
5
+ import { PostboyCallbackMessage } from '../models/postboy-callback.message';
6
+ import { MessageHistoryItemMock } from './message-history-item-mock';
7
+ import { MessageType } from '../postboy-abstract.registrator';
8
+ export declare class PostboyServiceMock extends PostboyService {
9
+ private subscriptions;
10
+ private _history;
11
+ reset(): void;
12
+ fired(id: string, times?: number): boolean;
13
+ subscribed(id: string, times?: number): boolean;
14
+ private count;
15
+ exec<E extends PostboyExecutor<T>, T>(executor: E): T;
16
+ subscribe<T>(id: string): Observable<T>;
17
+ sub<T extends PostboyGenericMessage>(type: MessageType<T>): Observable<T>;
18
+ fire<T extends PostboyGenericMessage>(message: T): void;
19
+ fireCallback<T>(message: PostboyCallbackMessage<T>, action?: (e: T) => void): void;
20
+ history<T extends PostboyGenericMessage>(type: MessageType<T>): MessageHistoryItemMock<T>;
21
+ }
22
22
  //# sourceMappingURL=postboy-service-mock.d.ts.map
@@ -1,51 +1,51 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PostboyServiceMock = void 0;
4
- const postboy_service_1 = require("../postboy.service");
5
- const postboy_generic_message_1 = require("../models/postboy-generic-message");
6
- const message_history_mock_1 = require("./message-history-mock");
7
- class PostboyServiceMock extends postboy_service_1.PostboyService {
8
- constructor() {
9
- super(...arguments);
10
- this.subscriptions = [];
11
- this._history = new message_history_mock_1.MessageHistoryMock();
12
- this.count = (collection, el) => collection.filter((e) => e === el).length;
13
- }
14
- reset() {
15
- this.subscriptions = [];
16
- this._history.reset();
17
- }
18
- fired(id, times = 0) {
19
- var _a;
20
- return ((_a = this._history.get(id)) === null || _a === void 0 ? void 0 : _a.length) === times;
21
- }
22
- subscribed(id, times = 0) {
23
- const count = this.count(this.subscriptions, id);
24
- return !!count && (!times || count === times);
25
- }
26
- exec(executor) {
27
- this._history.add(executor);
28
- return super.exec(executor);
29
- }
30
- subscribe(id) {
31
- this.subscriptions.push(id);
32
- return super.subscribe(id);
33
- }
34
- sub(type) {
35
- this.subscriptions.push((0, postboy_generic_message_1.checkId)(type));
36
- return super.subscribe((0, postboy_generic_message_1.checkId)(type));
37
- }
38
- fire(message) {
39
- this._history.add(message);
40
- super.fire(message);
41
- }
42
- fireCallback(message, action) {
43
- this._history.add(message);
44
- return super.fireCallback(message, action);
45
- }
46
- history(type) {
47
- return this._history.get((0, postboy_generic_message_1.checkId)(type));
48
- }
49
- }
50
- exports.PostboyServiceMock = PostboyServiceMock;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PostboyServiceMock = void 0;
4
+ const postboy_service_1 = require("../postboy.service");
5
+ const postboy_generic_message_1 = require("../models/postboy-generic-message");
6
+ const message_history_mock_1 = require("./message-history-mock");
7
+ class PostboyServiceMock extends postboy_service_1.PostboyService {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.subscriptions = [];
11
+ this._history = new message_history_mock_1.MessageHistoryMock();
12
+ this.count = (collection, el) => collection.filter((e) => e === el).length;
13
+ }
14
+ reset() {
15
+ this.subscriptions = [];
16
+ this._history.reset();
17
+ }
18
+ fired(id, times = 0) {
19
+ var _a;
20
+ return ((_a = this._history.get(id)) === null || _a === void 0 ? void 0 : _a.length) === times;
21
+ }
22
+ subscribed(id, times = 0) {
23
+ const count = this.count(this.subscriptions, id);
24
+ return !!count && (!times || count === times);
25
+ }
26
+ exec(executor) {
27
+ this._history.add(executor);
28
+ return super.exec(executor);
29
+ }
30
+ subscribe(id) {
31
+ this.subscriptions.push(id);
32
+ return super.subscribe(id);
33
+ }
34
+ sub(type) {
35
+ this.subscriptions.push((0, postboy_generic_message_1.checkId)(type));
36
+ return super.subscribe((0, postboy_generic_message_1.checkId)(type));
37
+ }
38
+ fire(message) {
39
+ this._history.add(message);
40
+ super.fire(message);
41
+ }
42
+ fireCallback(message, action) {
43
+ this._history.add(message);
44
+ return super.fireCallback(message, action);
45
+ }
46
+ history(type) {
47
+ return this._history.get((0, postboy_generic_message_1.checkId)(type));
48
+ }
49
+ }
50
+ exports.PostboyServiceMock = PostboyServiceMock;
51
51
  //# sourceMappingURL=postboy-service-mock.js.map