Constructor
new Observer(callback, …args)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback | function | ||
args | * | <repeatable> |
- Since
- 1.0.0
- Copyright
- schukai GmbH
- License
- AGPLv3
Example
import {Observer} from '@schukai/monster/source/types/observer.mjs';
const observer = new Observer(function (a, b, c) {
console.log(this, a, b, c); // ↦ "a", 2, true
}, "a", 2, true);
observer.update({value: true}).then(() => {
});
// ↦ {value: true} "a" 2 true
Members
(static) instanceSymbol
This method is called by the
instanceof
operator.This method is called by the instanceof
operator.
- Since
- 2.1.0
Methods
addTag(tag) → {Observer}
Parameters:
Name | Type | Description |
---|---|---|
tag | string |
Returns:
- Type:
- Observer
getTags() → {Array}
Returns:
- Type:
- Array
hasTag(tag) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
tag | string |
Returns:
- Type:
- boolean
removeTag(tag) → {Observer}
Parameters:
Name | Type | Description |
---|---|---|
tag | string |
Returns:
- Type:
- Observer
update(subject) → {Promise}
Parameters:
Name | Type | Description |
---|---|---|
subject | object |
Returns:
- Type:
- Promise