Constructor
new ProxyObserver(object)
Parameters:
Name | Type | Description |
---|---|---|
object | object |
- Since
- 1.0.0
- Copyright
- schukai GmbH
- License
- AGPLv3
Throws:
value is not a object
- Type
- TypeError
Example
import {ProxyObserver} from '@schukai/monster/source/types/proxyobserver.mjs';
import {Observer} from '@schukai/monster/source/types/observer.mjs';
import {isObject} from '@schukai/monster/source/types/is.mjs';
const o = new Observer(function () {
if (isObject(this) && this instanceof ProxyObserver) {
// do something (this ist ProxyObserver)
const subject = this.getSubject();
console.log(subject);
}
});
let realSubject = {
a: {
b: {
c: true
},
d: 9
}
}
const p = new ProxyObserver(realSubject);
p.attachObserver(o);
const s = p.getSubject();
s.a.b.c = false;
Members
(static) instanceSymbol
This method is called by the
instanceof
operator.This method is called by the instanceof
operator.
- Since
- 2.1.0
Methods
attachObserver(observer) → {ProxyObserver}
attach a new observer
.attach a new observer
Parameters:
Name | Type | Description |
---|---|---|
observer | Observer |
Returns:
- Type:
- ProxyObserver
containsObserver(observer) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
observer | Observer |
Returns:
- Type:
- boolean
detachObserver(observer) → {ProxyObserver}
detach a observer
.detach a observer
Parameters:
Name | Type | Description |
---|---|---|
observer | Observer |
Returns:
- Type:
- ProxyObserver
getRealSubject() → {object}
Get the real object
Changes to this object are not noticed by the observers, so you can make a large number of changes and inform the observers later.
Get the real object
Changes to this object are not noticed by the observers, so you can make a large number of changes and inform the observers later.
Returns:
- Type:
- object
getSubject() → {object}
Returns:
- Type:
- object
notifyObservers() → {Promise}
notify all observer
.notify all observer
Returns:
- Type:
- Promise
setSubject(obj) → {Monster.Types.ProxyObserver}
Parameters:
Name | Type | Description |
---|---|---|
obj | Object |
- Since
- 1.24.0
Returns: