Hello
I'm trying to get element from the DOM and set it's text content, I managed to make it work, but the way I did it doesn't seem right to me
const getElement = id => IO(() => document.querySelector(id))
const setElementText = element => text => IO(() => element.textContent = text)
getElement('h1').map(setElementText).run()('New Title').run() // it works
I am calling "run()" twice and I believe it should be called once. Btw I know I can just swap argument position in "setElementText" function so I accept "text" first then "element" then I would be able to call "run()" once and it would work. But I am interested is there a better solution for example above.
Hello I'm trying to get element from the DOM and set it's text content, I managed to make it work, but the way I did it doesn't seem right to me
I am calling "run()" twice and I believe it should be called once. Btw I know I can just swap argument position in "setElementText" function so I accept "text" first then "element" then I would be able to call "run()" once and it would work. But I am interested is there a better solution for example above.