The proposal is to remove the app's root property and do the same passing it in the second argument to app().
app({ init, view, state, actions, root })
app({ init, view, state, actions }, root)
e.g.
app(
{
init,
view,
state,
actions
},
document.getElementById("app")
)
Pros
render(elm, root), Elm's Elm.Main.embed(root), mithril's m,mount(document.body, Counter) (the order is reversed here though), Vue's $mount, etc.Cons
@JorgeBucaran how would this work with HOAs? Would they need to accept multiple args as well, and call the app function with both the props and root?
@okwolf Oh, I didn't think about it. I am starting to dislike this proposal haha.
You could possibly separate the app factory and the render factory.
I think the current API works well. It's nice and clean.
On Sun, Oct 8, 2017, 11:10 AM Phips Peter notifications@github.com wrote:
You could possibly separate the app factory and the render factory.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/hyperapp/hyperapp/issues/410#issuecomment-335017109,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMpDr-4gQUvoiMGdeFHjrFs-ghMXLeBNks5sqPQIgaJpZM4PxvKh
.
I don't expect many people will actually include a root prop that often anyway, but instead let it fallback to default (document.body). I like the idea but the cons seem to outweigh the pros.
Thanks everyone! I'll keep things the way they are. 👍
Out of curiosity, what's the benefit of this change? I can't access Slack from work to read the conversation.
Now, with HOA builtin support pushed to userland, we can revive this and as per discussion on Slack. Shall we implement it?
I prefer it but I do think we should have principles for why to answer @SkaterDad
The real (not really) question is, how do we feel about formatters like prettier making the code this:
app(
{
init,
view,
state,
actions
},
document.getElementById("app")
)
@SkaterDad The convo was basically that since builtin HOA support is out, and:
Complicates the signature of HOAs. Thanks @okwolf.
...was one of the reasons to turn this down, we can implement it now. Preact/React/Inferno users trying Hyperapp will feel at home and we can save some bytes too.
I still want to make sure we have consistent reasoning for API changes. As we approach 1.0, the API will become locked.
Well, let's approach it this way. What's not to like about
app(props, container)
app(
{
init,
view,
state,
actions
},
document.getElementById("app")
)
app({ init, view, state, actions }, document.getElementById("app"))
@JorgeBucaran FYI using this also breaks your compose function.
@okwolf Thanks, I'll update it.