Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it wrong to call "run()" two times in a row? #253

Open
Djordjenp opened this issue Jan 31, 2022 · 1 comment
Open

Is it wrong to call "run()" two times in a row? #253

Djordjenp opened this issue Jan 31, 2022 · 1 comment

Comments

@Djordjenp
Copy link

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.

@ulfryk
Copy link
Member

ulfryk commented Nov 19, 2024

@Djordjenp please see #258

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants