diff --git a/src/app/formulaire/ngparam.ts b/src/app/formulaire/ngparam.ts index dd7fb6554cfbcd3e01fae5d742329d07252e28f6..7556284a40a143904966a9df781b60ca52e5a76d 100644 --- a/src/app/formulaire/ngparam.ts +++ b/src/app/formulaire/ngparam.ts @@ -81,7 +81,6 @@ export class NgParameter extends InputField implements IObservable { constructor(private _paramDef: ParamDefinition, formId: number) { super(_paramDef.computeNodeType, _paramDef.symbol, formId); this._observable = new Observable(); - this._observable.sender = this; } get symbol(): string { @@ -305,6 +304,6 @@ export class NgParameter extends InputField implements IObservable { * notifie un événement aux observateurs */ public notifyObservers(data: any) { - this._observable.notifyObservers(data); + this._observable.notifyObservers(data, this); } } diff --git a/src/app/services/observer.ts b/src/app/services/observer.ts index d80be81107c3e538079381168b53802e65d1bda1..e33135c05fe08f99299b4949228f1bd9fcba059c 100644 --- a/src/app/services/observer.ts +++ b/src/app/services/observer.ts @@ -16,21 +16,14 @@ export interface IObservable { /** * notifie un événement aux observateurs */ - notifyObservers(data: any); + notifyObservers(data: any, sender?: any); } export class Observable implements IObservable { private _observers: Observer[]; - private _sender: IObservable; - constructor() { this._observers = []; - this._sender = this; - } - - public set sender(s: IObservable) { - this._sender = s; } /** @@ -51,8 +44,10 @@ export class Observable implements IObservable { /** * notifie un événement aux observateurs */ - public notifyObservers(data: any) { + public notifyObservers(data: any, sender?: any) { + if (sender == undefined) + sender = this; for (let o of this._observers) - o.update(this._sender, data); + o.update(sender, data); } }