@rxap/ngx-pub-sub 16.0.1-dev.0
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.
- package/CHANGELOG.md +8 -0
- package/LICENSE +621 -0
- package/LICENSE.md +621 -0
- package/README.md +21 -0
- package/esm2022/index.mjs +8 -0
- package/esm2022/lib/message-meta-data.mjs +62 -0
- package/esm2022/lib/provide.mjs +39 -0
- package/esm2022/lib/pub-sub-message.mjs +2 -0
- package/esm2022/lib/pub-sub.service.mjs +158 -0
- package/esm2022/lib/tokens.mjs +18 -0
- package/esm2022/rxap-ngx-pub-sub.mjs +5 -0
- package/fesm2022/rxap-ngx-pub-sub.mjs +281 -0
- package/fesm2022/rxap-ngx-pub-sub.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/message-meta-data.d.ts +62 -0
- package/lib/provide.d.ts +6 -0
- package/lib/pub-sub-message.d.ts +14 -0
- package/lib/pub-sub.service.d.ts +56 -0
- package/lib/tokens.d.ts +5 -0
- package/package.json +53 -0
- package/theme.css +1 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export declare class MessageMetaData<T = unknown> {
|
|
2
|
+
/**
|
|
3
|
+
* Original topic associated to the message.
|
|
4
|
+
* @private
|
|
5
|
+
*/
|
|
6
|
+
private readonly _topic;
|
|
7
|
+
/**
|
|
8
|
+
* Data associated to message. It's optional.
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
private readonly _data?;
|
|
12
|
+
/**
|
|
13
|
+
* A unique identifier of the message sent through the events bus.
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
private readonly _id;
|
|
17
|
+
/**
|
|
18
|
+
* Time in milliseconds in which the message was generated.
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
private readonly _timestamp;
|
|
22
|
+
/**
|
|
23
|
+
* Constructor for this class.
|
|
24
|
+
*
|
|
25
|
+
* @param _topic Original topic associated to the message sent through the events bus.
|
|
26
|
+
* @param [_data] Optional: Additional data sent with the message.
|
|
27
|
+
*/
|
|
28
|
+
constructor(
|
|
29
|
+
/**
|
|
30
|
+
* Original topic associated to the message.
|
|
31
|
+
* @private
|
|
32
|
+
*/
|
|
33
|
+
_topic: string,
|
|
34
|
+
/**
|
|
35
|
+
* Data associated to message. It's optional.
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
_data?: T | undefined);
|
|
39
|
+
/**
|
|
40
|
+
* Gets unique identifier of the message sent through the events bus.
|
|
41
|
+
*/
|
|
42
|
+
get id(): string;
|
|
43
|
+
/**
|
|
44
|
+
* Original topic associated to the message.
|
|
45
|
+
*/
|
|
46
|
+
get topic(): string;
|
|
47
|
+
/**
|
|
48
|
+
* Data associated to message. It's optional.
|
|
49
|
+
*/
|
|
50
|
+
get data(): T | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Gets the time in milliseconds in which the message was generated.
|
|
53
|
+
*/
|
|
54
|
+
get timestamp(): number;
|
|
55
|
+
/**
|
|
56
|
+
* Generates UUID version 4. The solution above uses Math.random() for brevity, however Math.random() is not
|
|
57
|
+
* guaranteed to be a high-quality RNG.
|
|
58
|
+
*
|
|
59
|
+
* @return UUID version 4.
|
|
60
|
+
*/
|
|
61
|
+
private uuid;
|
|
62
|
+
}
|
package/lib/provide.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Provider } from '@angular/core';
|
|
2
|
+
export declare function ProvidePubSub(...providers: Provider[]): Provider[];
|
|
3
|
+
export declare function withDisableCache(): Provider;
|
|
4
|
+
export declare function withDisableGarbageCollector(): Provider;
|
|
5
|
+
export declare function withMaxCacheSize(size: number): Provider;
|
|
6
|
+
export declare function withGarbageCollectorInterval(interval: number): Provider;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MessageMetaData } from './message-meta-data';
|
|
2
|
+
export interface PubSubMessage<T = unknown> {
|
|
3
|
+
/**
|
|
4
|
+
* Key to identify message.
|
|
5
|
+
*/
|
|
6
|
+
topic: string;
|
|
7
|
+
/**
|
|
8
|
+
* Full message metadata.
|
|
9
|
+
*/
|
|
10
|
+
metadata: MessageMetaData<T>;
|
|
11
|
+
}
|
|
12
|
+
export interface CachedPubSubMessage<T = unknown> extends PubSubMessage<T> {
|
|
13
|
+
retention?: number;
|
|
14
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { OnDestroy } from '@angular/core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { MessageMetaData } from './message-meta-data';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export declare class PubSubService implements OnDestroy {
|
|
6
|
+
/**
|
|
7
|
+
* Main observable to multicast to all observers.
|
|
8
|
+
*/
|
|
9
|
+
private readonly messageBus;
|
|
10
|
+
private readonly cache;
|
|
11
|
+
private maxCacheSize;
|
|
12
|
+
/**
|
|
13
|
+
* Topic message separator.
|
|
14
|
+
*/
|
|
15
|
+
private readonly separator;
|
|
16
|
+
private readonly garbageCollectorInterval;
|
|
17
|
+
private readonly disableCache;
|
|
18
|
+
private readonly disableGarbageCollector;
|
|
19
|
+
private garbageCollectorSubscription;
|
|
20
|
+
private garbageCollectorInitialized;
|
|
21
|
+
get cacheSize(): number;
|
|
22
|
+
setMaxCacheSize(size: number): void;
|
|
23
|
+
startGarbageCollector(): void;
|
|
24
|
+
runGarbageCollector(): void;
|
|
25
|
+
stopGarbageCollector(): void;
|
|
26
|
+
ngOnDestroy(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Validates topic matching.
|
|
29
|
+
*
|
|
30
|
+
* @param topic Topic to identify the message/event.
|
|
31
|
+
* @param wildcard Wildcard received from on method.
|
|
32
|
+
*
|
|
33
|
+
* @return true if topic matches, false otherwise.
|
|
34
|
+
*/
|
|
35
|
+
topicMatch(topic: string, wildcard: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* @param topic Topic to identify the message.
|
|
38
|
+
* @param [data] Optional: Additional data sent with the message.
|
|
39
|
+
* @param [retention] Optional: Retention time in milliseconds.
|
|
40
|
+
* @throws {Error} topic parameter must be a string and must not be empty.
|
|
41
|
+
*/
|
|
42
|
+
publish<T = unknown>(topic: string, data?: T, retention?: number): void;
|
|
43
|
+
/**
|
|
44
|
+
* @param topic Topic to identify the message.
|
|
45
|
+
* @param replayCount Number of messages to replay.
|
|
46
|
+
* @return Observable you can subscribe to listen messages.
|
|
47
|
+
*/
|
|
48
|
+
subscribe<T = unknown>(topic: string, replayCount?: number): Observable<MessageMetaData<T>>;
|
|
49
|
+
/**
|
|
50
|
+
* @param topic Topic to identify the message.
|
|
51
|
+
* @param limit Maximum number of messages to return.
|
|
52
|
+
*/
|
|
53
|
+
getFromCache<T = unknown>(topic: string, limit?: number): Array<MessageMetaData<T>>;
|
|
54
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PubSubService, never>;
|
|
55
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<PubSubService>;
|
|
56
|
+
}
|
package/lib/tokens.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
export declare const RXAP_PUB_SUB_CACHE_SIZE: InjectionToken<number>;
|
|
3
|
+
export declare const RXAP_PUB_SUB_GARBAGE_COLLECTOR_INTERVAL: InjectionToken<number>;
|
|
4
|
+
export declare const RXAP_PUB_SUB_DISABLE_CACHE: InjectionToken<boolean>;
|
|
5
|
+
export declare const RXAP_PUB_SUB_DISABLE_GARBAGE_COLLECTOR: InjectionToken<boolean>;
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "16.0.1-dev.0",
|
|
3
|
+
"name": "@rxap/ngx-pub-sub",
|
|
4
|
+
"license": "GPL-3.0-or-later",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"tslib": "^2.3.0"
|
|
7
|
+
},
|
|
8
|
+
"peerDependencies": {
|
|
9
|
+
"@angular/core": "^16.1.4",
|
|
10
|
+
"rxjs": "^7.8.0"
|
|
11
|
+
},
|
|
12
|
+
"author": {
|
|
13
|
+
"name": "Merzough Münker",
|
|
14
|
+
"email": "mmuenker@digitaix.com"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://gitlab.com/rxap/packages/-/issues",
|
|
18
|
+
"email": "incoming+rxap-packages-14898188-issue-@incoming.gitlab.com"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https:/gitlab.com/rxap/packages/packages/angular/pub-sub",
|
|
21
|
+
"keywords": [
|
|
22
|
+
"angular",
|
|
23
|
+
"angular-pub-sub",
|
|
24
|
+
"ngx",
|
|
25
|
+
"packages",
|
|
26
|
+
"rxap"
|
|
27
|
+
],
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public",
|
|
30
|
+
"directory": "../../../dist/packages/angular/pub-sub"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://gitlab.com/rxap/packages.git",
|
|
35
|
+
"directory": "packages/angular/pub-sub"
|
|
36
|
+
},
|
|
37
|
+
"sideEffects": false,
|
|
38
|
+
"gitHead": "b80ce9606a060ca90afe6141ec25b8d6620d70ad",
|
|
39
|
+
"module": "fesm2022/rxap-ngx-pub-sub.mjs",
|
|
40
|
+
"typings": "index.d.ts",
|
|
41
|
+
"exports": {
|
|
42
|
+
"./package.json": {
|
|
43
|
+
"default": "./package.json"
|
|
44
|
+
},
|
|
45
|
+
".": {
|
|
46
|
+
"types": "./index.d.ts",
|
|
47
|
+
"esm2022": "./esm2022/rxap-ngx-pub-sub.mjs",
|
|
48
|
+
"esm": "./esm2022/rxap-ngx-pub-sub.mjs",
|
|
49
|
+
"default": "./fesm2022/rxap-ngx-pub-sub.mjs"
|
|
50
|
+
},
|
|
51
|
+
"./theme": "./theme.css"
|
|
52
|
+
}
|
|
53
|
+
}
|
package/theme.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}
|