From 90783572b460ee167597f44eda755f880485dcf9 Mon Sep 17 00:00:00 2001 From: Martin Karkowski Date: Sat, 8 Oct 2022 07:15:33 +0200 Subject: [PATCH] # 1.4.1 - Fixes: - Fixing time based issue in `ConnectivityManager` (using the now synced time for checkups) - `dispatchers.ConnectivityManager.ConnectivityManager`: fixing `_checkDispatcherHealth` - Fixing `extractUniqueValues` now it is possible to use different pathes for the `key` and `value` - `lib\helpers\mapMethods.ts` has been adapted - `lib\pubSub\nopePubSubSystem.ts` contains the following fixes: - fixing typo of method `updateMatching` - Modified: - `lib\pubSub\nopePubSubSystem.ts`: - throws error if `register` method doest not contain a topic. - Adapted the behavior of `_patternbasedPullData`. If no default default value is present -> the function returns an empty array. --- CHANGELOG.md | 8 ++++- lib/pubSub/nopePubSubSystem.ts | 37 ++++++++++++++++++----- lib/types/nope/nopePubSub.interface.ts | 6 ++-- py-helpers/02-prepare-js.bat | 2 +- py-helpers/prepare_code/post_processor.py | 3 +- 5 files changed, 42 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41541bc..31abd31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -265,4 +265,10 @@ Inital commit, which is working with the browser - Fixing time based issue in `ConnectivityManager` (using the now synced time for checkups) - `dispatchers.ConnectivityManager.ConnectivityManager`: fixing `_checkDispatcherHealth` - Fixing `extractUniqueValues` now it is possible to use different pathes for the `key` and `value` - - `lib\helpers\mapMethods.ts` has been adapted \ No newline at end of file + - `lib\helpers\mapMethods.ts` has been adapted + - `lib\pubSub\nopePubSubSystem.ts` contains the following fixes: + - fixing typo of method `updateMatching` + - Modified: + - `lib\pubSub\nopePubSubSystem.ts`: + - throws error if `register` method doest not contain a topic. + - Adapted the behavior of `_patternbasedPullData`. If no default default value is present -> the function returns an empty array. \ No newline at end of file diff --git a/lib/pubSub/nopePubSubSystem.ts b/lib/pubSub/nopePubSubSystem.ts index 8f601d0..c477115 100644 --- a/lib/pubSub/nopePubSubSystem.ts +++ b/lib/pubSub/nopePubSubSystem.ts @@ -42,6 +42,8 @@ type TMatchting = { dataQuery: Map>; }; +const DEFAULT_OBJ = {id:"default"}; + export class PubSubSystemBase< AD extends ITopicSetContentOptions & { pubSubUpdate?: boolean; @@ -171,6 +173,11 @@ export class PubSubSystemBase< // See interface description public register(emitter: I, options: IEventOptions): O { if (!this._emitters.has(emitter as unknown as O)) { + + if (typeof(options.topic) !== "string" && typeof(options.topic) !== "object"){ + throw Error("A Topic must be provided in the options.") + } + let pubTopic: string | false = typeof options.topic === "string" ? options.topic @@ -393,7 +400,7 @@ export class PubSubSystemBase< * @author M.Karkowski * @memberof PubSubSystemBase */ - public updateMatchting(): void { + public updateMatching(): void { // Clears all defined Matches this._matched.clear(); // Iterate through all Publishers and @@ -770,7 +777,7 @@ export class PubSubSystemBase< */ protected _patternbasedPullData( pattern: string, - _default: D = null + _default: D = undefined ): { path: string; data: T }[] { // To extract the data based on a Pattern, // we firstly, we check if the given pattern @@ -778,12 +785,26 @@ export class PubSubSystemBase< if (!containsWildcards(pattern)) { // Its not a pattern so we will speed up // things. - return [ - { - path: pattern, - data: this._pullData(pattern, _default), - }, - ]; + + const data:T = this._pullData(pattern, DEFAULT_OBJ); + + if (data !== DEFAULT_OBJ) { + return [ + { + path: pattern, + data, + }, + ]; + } else if (_default !== undefined) { + return [ + { + path: pattern, + data: _default as any as T, + }, + ]; + } + + return [] } // Now we know, we have to work with the query, diff --git a/lib/types/nope/nopePubSub.interface.ts b/lib/types/nope/nopePubSub.interface.ts index e8fb988..423927e 100644 --- a/lib/types/nope/nopePubSub.interface.ts +++ b/lib/types/nope/nopePubSub.interface.ts @@ -198,7 +198,7 @@ export interface IPubSubSystem< * @author M.Karkowski * @memberof IPubSubSystem */ - updateMatchting(): void; + updateMatching(): void; /** * An observable which holds the incremental data change. @@ -317,8 +317,8 @@ export interface IDataPubSubSystem< * @author M.Karkowski * @template T * @template D - * @param {string} pattern - * @param {D} _default + * @param {string} pattern The pattern to pull the data from + * @param {D} _default a default value, o * @return {*} {{ path: string, data: T }[]} * @memberof IPubSubSystem */ diff --git a/py-helpers/02-prepare-js.bat b/py-helpers/02-prepare-js.bat index 9e9ca28..3c6311f 100644 --- a/py-helpers/02-prepare-js.bat +++ b/py-helpers/02-prepare-js.bat @@ -3,4 +3,4 @@ cd "%DIR%" cd .. rm -rf temp -nope-py-prepare-code --input dist-py --output temp --type js \ No newline at end of file +nope-py-prepare-code --input dist-py --output temp --type js --convert_snake_case \ No newline at end of file diff --git a/py-helpers/prepare_code/post_processor.py b/py-helpers/prepare_code/post_processor.py index 9ac5770..8c72e47 100644 --- a/py-helpers/prepare_code/post_processor.py +++ b/py-helpers/prepare_code/post_processor.py @@ -23,7 +23,8 @@ replacers = { '"undefined"': "None", 'undefined': "None", 'self = self': "", - "__definition_of__": "" + "__definition_of__": "", + "@property()": "@property", } def post_process(code: str) -> str: