/** * @author Martin Karkowski * @email m.karkowski@zema.de * @create date 2018-05-22 01:13:13 * @modify date 2020-08-25 16:27:39 * @desc [description] */ /** Clear the Screen */ declare const process: any; import { inject, injectable } from 'inversify'; import { generateBenchmarkFunction } from '../../funcs/generateBenchmarkFunction'; import { Builder } from '../../mod-Assembly-Builder/src/Container-Builder.FileLoader'; import { SystemLogger } from '../../mod-Logger/src/Unique.Logger'; import * as PUBSUB from '../assembly/manual-assembly'; import { addObservables, GenericObservable } from '../src/Pub-Sub-Observable'; /** Add the Observer-ActivationHandler */ Builder.instance.addElements(PUBSUB.EXPORT) Builder.instance.addActivationHandler(addObservables); /** Trigger Loading the Modules */ Builder.load(); Builder.on('loaded', () => { SystemLogger.logger.level = 'info'; /** Define a Class containing an observable @see attribute_01 */ @injectable() class TestClass implements PUBSUB.ContainsSharedObservables { shareConfig: { [index: string]: PUBSUB.ShareConfig }; path: string = ''; observables: Map>; initObservables(): void { /** Set a Value */ this.attribute_01.value = 0; } /** * Defining the Attribute as observable * * @type {PUBSUB.Observable} * @memberof TestClass */ @inject(PUBSUB.TYPES.Observable) public attribute_01: PUBSUB.Observable; /** * Creates an instance of TestClass. * @memberof TestClass */ constructor() { /** Set a Values - That must be done during the construction */ this.path = ''; this.observables = new Map>(); this.shareConfig = {}; this.shareConfig.attribute_01 = { useAutoPathForPublishing: true, useAutoPathForSubscribing: true } } } /** Create a Definition for the Builder */ const _definition = [{ selector: 'Test', type: TestClass }]; /** Add the Definition to the Builder */ Builder.instance.addElements(_definition); /** Generate an Object of the Test-Class */ const _test = Builder.instance.container.get("Test"); /** Create the Benchmark Module */ const _max = 10000000; _test.attribute_01.subscribe(generateBenchmarkFunction(_max, ''), 'sync'); let i = 10; let counter = _max; while (i >= 0) { counter = _max while (counter >= 0) { _test.attribute_01.setContent(counter--); } i--; } counter = _max * 4; while (counter >= 0) { _test.attribute_01.value = counter--; } _test.path = 'test'; const _pubSub: PUBSUB.PubSubSystem = Builder.instance.container.get(PUBSUB.TYPES.PubSubSystem); _pubSub.createSubscription('test.#', (content, sender) => { console.log('Pubsub', content); }); _pubSub.createPublisher('test.attribute_01').publishData(1337) });