Сеттер нужен наверное...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>html{font:2em sans-serif;}</style>
</head>
<body>
<div id="lorem"></div>
<script>
function createSetter(element, variable, context) {
Object.defineProperty(context || self, variable, {
set: function(value) {
console.log(value);
let x = Symbol.for("textContentPromise");
let promise = element[x] || Promise.resolve();
element[x] = promise.then(() => {
return new Promise(resolve => {
setTimeout(() => resolve(element.textContent = value), 200);
});
});
}
});
}
createSetter(lorem, "text");
text = "lorem";
text = "ipsum";
text = "dolor";
text = "sit";
text = "amet";
text = "Rise";
text = "как";
text = "видишь";
text = "заметно";
text = "и";
text = "на";
text = "обычном";
text = "компе";
text = "lorem";
text = "ipsum";
text = "dolor";
text = "sit";
text = "amet";
</script>
</body>
</html>