- 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.
This commit is contained in:
Martin Karkowski 2022-10-08 07:15:33 +02:00
parent fa234b9a9b
commit 90783572b4
5 changed files with 42 additions and 14 deletions

View File

@ -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) - Fixing time based issue in `ConnectivityManager` (using the now synced time for checkups)
- `dispatchers.ConnectivityManager.ConnectivityManager`: fixing `_checkDispatcherHealth` - `dispatchers.ConnectivityManager.ConnectivityManager`: fixing `_checkDispatcherHealth`
- Fixing `extractUniqueValues` now it is possible to use different pathes for the `key` and `value` - Fixing `extractUniqueValues` now it is possible to use different pathes for the `key` and `value`
- `lib\helpers\mapMethods.ts` has been adapted - `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.

View File

@ -42,6 +42,8 @@ type TMatchting<O extends INopeTopic = INopeTopic> = {
dataQuery: Map<string, Set<O>>; dataQuery: Map<string, Set<O>>;
}; };
const DEFAULT_OBJ = {id:"default"};
export class PubSubSystemBase< export class PubSubSystemBase<
AD extends ITopicSetContentOptions & { AD extends ITopicSetContentOptions & {
pubSubUpdate?: boolean; pubSubUpdate?: boolean;
@ -171,6 +173,11 @@ export class PubSubSystemBase<
// See interface description // See interface description
public register(emitter: I, options: IEventOptions): O { public register(emitter: I, options: IEventOptions): O {
if (!this._emitters.has(emitter as unknown as 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 = let pubTopic: string | false =
typeof options.topic === "string" typeof options.topic === "string"
? options.topic ? options.topic
@ -393,7 +400,7 @@ export class PubSubSystemBase<
* @author M.Karkowski * @author M.Karkowski
* @memberof PubSubSystemBase * @memberof PubSubSystemBase
*/ */
public updateMatchting(): void { public updateMatching(): void {
// Clears all defined Matches // Clears all defined Matches
this._matched.clear(); this._matched.clear();
// Iterate through all Publishers and // Iterate through all Publishers and
@ -770,7 +777,7 @@ export class PubSubSystemBase<
*/ */
protected _patternbasedPullData<T = unknown, D = null>( protected _patternbasedPullData<T = unknown, D = null>(
pattern: string, pattern: string,
_default: D = null _default: D = undefined
): { path: string; data: T }[] { ): { path: string; data: T }[] {
// To extract the data based on a Pattern, // To extract the data based on a Pattern,
// we firstly, we check if the given pattern // we firstly, we check if the given pattern
@ -778,12 +785,26 @@ export class PubSubSystemBase<
if (!containsWildcards(pattern)) { if (!containsWildcards(pattern)) {
// Its not a pattern so we will speed up // Its not a pattern so we will speed up
// things. // things.
return [
{ const data:T = this._pullData(pattern, DEFAULT_OBJ);
path: pattern,
data: this._pullData(pattern, _default), 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, // Now we know, we have to work with the query,

View File

@ -198,7 +198,7 @@ export interface IPubSubSystem<
* @author M.Karkowski * @author M.Karkowski
* @memberof IPubSubSystem * @memberof IPubSubSystem
*/ */
updateMatchting(): void; updateMatching(): void;
/** /**
* An observable which holds the incremental data change. * An observable which holds the incremental data change.
@ -317,8 +317,8 @@ export interface IDataPubSubSystem<
* @author M.Karkowski * @author M.Karkowski
* @template T * @template T
* @template D * @template D
* @param {string} pattern * @param {string} pattern The pattern to pull the data from
* @param {D} _default * @param {D} _default a default value, o
* @return {*} {{ path: string, data: T }[]} * @return {*} {{ path: string, data: T }[]}
* @memberof IPubSubSystem * @memberof IPubSubSystem
*/ */

View File

@ -3,4 +3,4 @@ cd "%DIR%"
cd .. cd ..
rm -rf temp rm -rf temp
nope-py-prepare-code --input dist-py --output temp --type js nope-py-prepare-code --input dist-py --output temp --type js --convert_snake_case

View File

@ -23,7 +23,8 @@ replacers = {
'"undefined"': "None", '"undefined"': "None",
'undefined': "None", 'undefined': "None",
'self = self': "", 'self = self': "",
"__definition_of__": "" "__definition_of__": "",
"@property()": "@property",
} }
def post_process(code: str) -> str: def post_process(code: str) -> str: