return {
...state,
user : {
...state.user,
[action.prop] : action.value
}
}
function printer(str, elem) {
return new Promise((resolve) => {
const chars = str.split('');
const t = setInterval(() => {
if (chars.length) {
elem.textContent = elem.textContent + chars[0];
chars.shift();
} else {
resolve();
clearInterval(t);
}
}, 100);
});
}
printer('Добро Пожаловать ', document.getElementById('test1')).then(() => {
printer('SlivCours', document.getElementById('test2'));
});