-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
Consider exposing snabbdom lifecycle hooks #137
Comments
Just digging into this a bit... no conclusions just making notes (and I'm conscious that I'm doing this while slightly tired and may be talking nonsense!). The first observation is that I think I was wrong about the original Scalm implementation of hooks. I'd leapt to the conclusion that it was exposing the Snabbdom hooks system, but that doesn't actually appear to be the case. I think what it did was to allow you to include entire arbitrary Snabbdom html. A link for the curious: My feeling is that bringing this back would not be enough, the reason is that the main use case seems to be the desire to detect node creation for loading in React components and such. So one could actually expose Snabbdom on purpose to allow people to take advantage of everything Snabbdom can do, hooks n' all. It's the shortest route to market but crucially it wouldn't tie into the Tyrian message loop. So by some funky callback process you could maybe inform a Sub that something had happened, but it wouldn't be a nice integrated experience of the kind expressed in the original issue description. Assuming we don't want that then, the next approach is to expose our own hooks api underpinned by some of the Snabbdom implementation. Snabbdom exposes a lot of hooks: https://github.com/snabbdom/snabbdom#overview Which ones do we really care about as web app builders?
(I'm not convinced I understand the Snabbdom hook descriptions entirely yet. I'll need to have a play with them.) Then if we decide to go ahead, we get on to how to make them available. I feel like hooks are an advanced feature and I'd rather people didn't create them by accident because they looked like attributes - but maybe I'm overthinking this...? I'm wondering about something like this: div(id := "abc123")(
p("Hello!").withHooks(
onCreate(Msg.Created),
onRemove(Msg.Removed)
)
) Or at first glance I kinda prefer this... div(id := "abc123")(
Watch(onCreate(Msg.Created), onRemove(Msg.Removed)) {
p("Hello!")
}
) (Note: I have not checked to see if these are possible. They are entirely made up!) Thoughts welcome. |
Having an access to some hooks would make it easier to integrate with outside systems and third-party code - like rendering React/Preact/X components inside Tyrian.
I'm not sure about the API, but probably sth like this would be fine:
The text was updated successfully, but these errors were encountered: