Skip to content

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

Description

@Djordjenp

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions