Hi
I found this interesting code...
I'm curious, how does one create this in BANano? I can understand some of the portions here but..., how do I write this in BANano to a working example?
Thanks in advance.
I found this interesting code...
B4X:
const Hoc = (updateCounter) => {
let counter = 0;
// Hoc function
function increaseCounter() {
counter++;
updateCounter(counter);
}
return { increase: increaseCounter };
};
const btn = document.getElementById('btn');
const label = document.getElementById('label');
const buttonHoc = Hoc((count) => {
btn.textContent = `Btn clicks count: ${count}`;
});
const labelHoc = Hoc((count) => {
label.textContent = `Mouse out count: ${count}`;
});
// Adding event listeners
btn.addEventListener('click', () => buttonHoc.increase());
label.addEventListener('mouseout', () => labelHoc.increase());
I'm curious, how does one create this in BANano? I can understand some of the portions here but..., how do I write this in BANano to a working example?
Thanks in advance.