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

Cleaning up effects from removed widget #40

Closed
justinlovinger opened this issue Feb 1, 2020 · 3 comments
Closed

Cleaning up effects from removed widget #40

justinlovinger opened this issue Feb 1, 2020 · 3 comments
Assignees

Comments

@justinlovinger
Copy link

Say that I have a widget that runs in parallel with an Effect, such as

canvas [ _id $ show canvasId ] []
  <|> (liftAff (runCanvas canvasId) *> empty)

I'm finding that, when this widget is removed, the runCanvas effect continues to run, and as this widget is removed and re-added, the effects stack, resulting is performance slowdown and memory buildup.

Does Concur have something like React's componentWillUnmount to clean up effects, like the example above.

@pkamenarsky
Copy link

I find myself in need of "widget finalisers" as well. My particular use case is a drag & drop implementation, for which I need to add event handlers to the document directly (so that mouse movements are registered outside the element, as well as browser). The problem is that without finalisers there's no way to remove the previously added event handlers if a Widget that's in the middle of a drag & drop cycle gets killed.

Maybe something like:

withFinaliser :: forall a. Effect Unit -> Widget v a -> Widget v a

where the effect would be called if the Widget itself or any of its parents gets killed.

@ajnsit
Copy link
Member

ajnsit commented Jun 2, 2020

Two developments -

  1. I have started working on a new VDom backend for Concur which uses Halogen-VDom. With this, I think we'll also be able to have components with internal persistent state, and initialisers and finalisers. I am still coming up with an appropriate API.

  2. I will be adding support for internal state, and React lifecycle methods such as componentWillUnmount to the React backend as well.

I hope to have the same unified API for both of these things.

@ajnsit
Copy link
Member

ajnsit commented Jun 6, 2020

We are going to track the lifecycle and local state implementation in an umbrella issue - #46. Closing this in favor of that issue.

@ajnsit ajnsit closed this as completed Jun 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants