Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/ilovecveti.ru/bitrix/js/bizproc/automation/src/context/ |
Upload File : |
import { Type, clone } from "main.core"; import { EventEmitter, BaseEvent } from "main.core.events"; export class BaseContext extends EventEmitter { #values: Object<string, any>; constructor(defaultValue: Object<string, any>) { super(); this.setEventNamespace('BX.Bizproc.Automation.Context'); if (Type.isPlainObject(defaultValue)) { this.#values = defaultValue; } } clone(): this { return new BaseContext(clone(this.#values)); } getValues(): object { return this.#values; } set(name: string, value: any): this { const isValueChanged = this.has(name); this.#values[name] = value; this.emit(isValueChanged ? 'valueChanged' : 'valueAdded', {name, value}) return this; } get(name: string): any { return this.#values[name]; } has(name: string): boolean { return this.#values.hasOwnProperty(name); } subsribeValueChanges(name: string, listener: (BaseEvent) => void): this { this.subscribe('valueChanged', (event) => { if (event.data.name === name) { listener(event); } }); return this; } }