Updater
The updater class connects an object with the dom
import { Updater } from "@schukai/monster/source/dom/updater.mjs";Simple Example
import {Updater} from '@schukai/monster/source/dom/updater.mjs';
// First, we prepare the HTML document.
// This is done here via a script, but can also be inserted into the document as pure HTML.
// To do this, simply insert the tag <h1 data-monster-replace="path:headline"></h1>
const body = document.querySelector('body');
const headline = document.createElement('h1');
headline.setAttribute('data-monster-replace', 'path:headline')
body.appendChild(headline);
// the data structure
let obj = {
headline: "Hello World",
};
// Now comes the real magic. We pass the updater the parent HTMLElement
// and the desired data structure.
const script = new Updater(body, obj);
script.run();
// Now you can change the data structure and the HTML will follow these changes.
const subject = script.getSubject();
subject['headline'] = "Hello World!"Exported
Updater, addObjectWithUpdaterToElementDerived from
BaseOptions
The Options listed in this section are defined directly within the class. This class is derived from several parent classes. Therefore, it inherits Options from these parent classes. If you cannot find a specific Options in this list, we recommend consulting the documentation of the Base.
Properties
The Properties listed in this section are defined directly within the class. This class is derived from several parent classes. Therefore, it inherits Properties from these parent classes. If you cannot find a specific Properties in this list, we recommend consulting the documentation of the Base.
Methods
The methods listed in this section are defined directly within the class. This class is derived from several parent classes. Therefore, it inherits methods from these parent classes. If you cannot find a specific method in this list, we recommend consulting the documentation of the Base.
Constructor
constructor(element,subject)1.8.0element{htmlelement}: elementsubject{object|proxyobserver|undefined}: subject
{TypeError}value is not a object{TypeError}value is not an instance of HTMLElement
Behavioral methods
disableEventProcessing()1.9.0- {Updater}
enableEventProcessing()1.9.0- {Updater}
{Error}the bind argument must start as a value with a path
updater.run().then(() => {
updater.enableEventProcessing();
});
Structural methods
getSubject()1.8.0- {Proxy}
setCallback(name,callback)name{string}: namecallback{function}: callback
- {Transformer}
{TypeError}value is not a string{TypeError}value is not a function
setEventTypes(types)1.9.0types{array}: types
- {Updater}
Other methods
retrieve()1.27.0- {Monster.DOM.Updater}
run()- {Promise}
updater.run().then(() => {
updater.enableEventProcessing();
});
undefined()- {Promise}
undefined(change)change
Events
This component does not fire any public events. It may fire events that are inherited from its parent classes.