Comments (8)
I think the case you're exploring there is a little different from how this was experienced.
I'm saying a child disappearing killed the current eval in the parent component. I agree that a child being removed should terminate any actions it is taking, I don't agree that it should also kill the eval that performed the removal when that eval arose from the child raising a message.
That doesn't seem like "cancelling a child's pending actions", since we're in the context of the parent at this point.
from purescript-halogen.
I've found another issue related to this: if you're handling the message from a child, and within that eval
you modify the state in such a way that the child is removed, it will immediately terminate the eval
after the state change. So:
HandleChildMessage _ -> do
traceM "Hello"
H.modify_ removeTheChildThatRaisedThisMessage
traceM "Goodbye"
The traceM "Goodbye"
is unreachable here.
from purescript-halogen.
I think that case is reasonable, where removing a child is equivalent to cancelling the child's pending actions. That is, it's equivalent to sending a kill to all fork ids, which is certainly a thing Halogen already exposes as part of it's API. I think that if you needed guarantees around uncancellable blocks of HalogenM, you'd need to provide an API for that (such as invincible
).
from purescript-halogen.
I think that case is reasonable, where removing a child is equivalent to cancelling the child's pending actions. That is, it's equivalent to sending a kill to all fork ids, which is certainly a thing Halogen already exposes as part of it's API. I think that if you needed guarantees around uncancellable blocks of HalogenM, you'd need to provide an API for that (such as
invincible
).
That's not what I would intuitively expect; the child notified the parent of a message, but that doesn't mean the parent will necessarily react by interacting with the child further.
As an analogy, if I am handling a click event in the DOM, I wouldn't expect my handler to get cancelled halfway through because the element that was clicked was removed in the meantime (though I would expect that attempting to interact with that element would now fail, the same way that H.query
will fail if the indicated child component has been removed)
from purescript-halogen.
But DOM handlers are synchronous and linear. Code in HalogenM is asynchronous and concurrent (regardless of what your m
is), so it requires concurrency semantics.
from purescript-halogen.
Perhaps another way of phrasing it:
someHalogenM = do
raise ...
lift $ Console.log "Hello"
eval = do
SomeAction ->
someHalogenM
AnotherAction ->
void $ H.fork someHalogenM
What happens here? There are a few possibilities:
- SomeAction continues execution because it's a "root eval" (ie not forked by the user), AnotherAction gets cancelled because it s a fork.
- They both continue execution because removing a child never invokes a cancellation of component fibers. This leads to pervasive leaks because you can never run potentially infinite async loops.
- They are both cancelled because the runtime treats managed forks (those forked by the runtime) identically to user forks.
To me, the third option is the only composable behavior since it's uniform. The first gives you observable differences in behavior, and IMO is non-composable since every root action gets the equivalent to an implicit invincible
. This means if you ever run an async loop of some kind, you need to remember to fork it or it will always leak.
The concurrency semantics of Aff (which Halogen piggy backs on) are such that everything is cancellable by default. If things should not be cancellable, then they need to be invoked through explicit regions (bracket, invincible, etc). I personally don't consider runtime managed forks to be an explicit region.
from purescript-halogen.
Oh, I see. I misunderstood the example. I should have read closer. Yes, I agree with you that a child disappearing should not result in the parent halting execution.
It sounds like the parent execution is being run within the context of the child's fiber execution.
from purescript-halogen.
Yeah, I'm pretty sure that's exactly the problem. 👍
It's a confusing example 😄
from purescript-halogen.
Related Issues (20)
- `tellAll` function is not re-exported in Halogen module
- Enabling `StateT` with `HalogenM` HOT 1
- Export tellAll from Halogen.Query to Halogen HOT 2
- Reading Effects chapter -> Could not match type ResponseFormat String with type AffjaxDriver HOT 4
- Question: how to handle events coming from a js app? HOT 2
- Communication with JS loaded via CDN HOT 2
- Child component gets rendered outside of parent, being moved to bottom of HTML body HOT 6
- Discussion: CSS strategy for halogen applications HOT 20
- Question: body-level events HOT 3
- Order of properties matters when using `value` with `min` / `max` for `InputRange` HOT 3
- Change kind of slots to not be `Type`
- `RenderSpec` doc comment still mentions `h` parameter
- Doc: the examples of "An Aff Example: HTTP Requests" give TypesDoNotUnify Error on Halogen v7 HOT 1
- Select Multiple Selected does not work HOT 4
- A bug? Weird behavior of text input fields. HOT 4
- Child component is destroyed while parent component handles output from that child HOT 5
- Array state updates HOT 4
- open and showModal are missing for dialog HOT 6
- The Component type should have role annotations
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from purescript-halogen.