Constructor
# new Observer(callback, …args)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function | ||
args |
* |
<repeatable> |
- Since:
- 1.0.0
- Copyright:
- schukai GmbH
Example
import {Observer} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.23.0/dist/modules/types/observer.js';
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
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