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

Interactions between Incr_dom and Effects #18

Open
Fitzgibbons opened this issue May 27, 2024 · 4 comments
Open

Interactions between Incr_dom and Effects #18

Fitzgibbons opened this issue May 27, 2024 · 4 comments
Labels
forwarded-to-js-devs This report has been forwarded to Jane Street's internal review system.

Comments

@Fitzgibbons
Copy link

Hi,

I recently tried to update an Incr_dom project with some code that uses effect handlers and ran into some issues. I've made a reproduction repo at incr_dom_effect_issue, and would appreciate advice on how to proceed.

While the example in the repo is reduced to something much simpler, the actual motivation for using effects in the first place is to synchronously wait on asynchronous javascript functions. I'm aware that this has drawbacks for the ui, but it seems reasonable in my case, as the asynchronous functions don't take long and are only called after button presses. If there's a more direct way to use asynchronous javascript functions from within Incr_dom I'd be happy to use it, but this feels like the "shape" of thing effects are good for, so I figured I'd ask the broader question.

Thanks,
Fitz

@TyOverby
Copy link
Member

Incr_dom hasn’t been tested with effect handlers yet, so I’m not surprised that there are issues. Could you describe the problem that you’re running into though?

@TyOverby
Copy link
Member

Oh sorry, I see now that you said that the effect triggers an “unhandled” exception. Thats expected because Incr_dom.start just schedules stuff to happen on future frames and it returns immediately, so your handler is done

@Fitzgibbons
Copy link
Author

Ah that makes sense. I don't have a good understanding of how Async ends up getting compiled to javascript, so it's possible I have a fundamental misunderstanding, but is there some way to effectively define my handler around the equivalent of Scheduler.go?

I'll also explore whether it's possible to move my effect handler into the apply_action function.

@TyOverby
Copy link
Member

I think that incr_dom would need custom logic in the event loop for effects to work

@github-iron github-iron added the forwarded-to-js-devs This report has been forwarded to Jane Street's internal review system. label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
forwarded-to-js-devs This report has been forwarded to Jane Street's internal review system.
Projects
None yet
Development

No branches or pull requests

3 participants