Mutations Constructos Removal Watch
Available since: 1.19.0
∯ Purpose
To call a function when a constructo was removed from DOM.
Syntax
Winnetou.mutations.start();
Winnetou.mutations.onRemove(id: String, callback: Function);
Winnetou.mutations.destroy()
start
Initiates watching DOM changes.
onRemove
Adds a listener to specific constructo that fires when it was removed from DOM.
destroy
Deletes mutations watching. Take when use destroy because it eliminates ALL mutations listeners on entire app.
Example
mutables.js
import {Winnetou} from 'winnetoujs';
import {profileCard} from './constructos/profile.js';
...
let profile = profileCard({
name:`John`
}).create(`#app`);
Winnetou.mutations.start();
Winnetou.mutations.onRemove(profile.ids.profileCard, () => {
console.log(`Profile was removed from dom.`)
});
Winnetou.mutations.destroy();