-
-
Notifications
You must be signed in to change notification settings - Fork 928
Closed
Labels
Area: CoreFor anything dealing with Mithril core itselfFor anything dealing with Mithril core itselfType: Breaking ChangeFor any feature request or suggestion that could reasonably break existing codeFor any feature request or suggestion that could reasonably break existing codeType: EnhancementFor any feature request or suggestion that isn't a bug fixFor any feature request or suggestion that isn't a bug fix
Description
Mithril version:
Platform and OS:
Project:
Is this something you're interested in implementing yourself?
Description
Depends on #2688 and #2689 - you can see the first because of the two-argument
view. It's easier to explain relative to this.
Replace these idioms:
const Comp = {
view(vnode, old) {
return tree
}
}
function Comp(initial) {
return {
view(vnode, old) {
return tree
}
}
}With these:
function Comp(attrs, old) {
return tree
}
function Comp(initial) {
return (attrs, old) => {
return tree
}
}As the rest of vnode.* properties are subsumed with other vnodes, I'd just provide the attrs themselves instead of full vnodes. (Vnode children would be moved to attrs.children to align with virtually every other framework out there - I don't see the benefit in us remaining special here.)
Why
- It's simpler to write.
- It's simpler to implement.
- It's lower overhead to invoke.
- Not much of a reason, but TS compatibility would be increased with this. If TS isn't, it'd be a much easier ask to get them to correct the incompatibility.
Possible Implementation
- In
createNode, change state initialization to just this:
var instance = (0, vnode.tag)(vnode.attrs)
if (typeof instance === "function") {
vnode.state = instance
vnode.instance = instance(vnode.attrs)
} else {
vnode.state = vnode.tag
vnode.instance = instance
}
// render vnode.instance as usual- In
updateNode, invoke(0, vnode.state)(vnode.attrs, old.attrs)instead ofvnode.state.view(vnode, old).
Open Questions
- Should we also kill
onInitfromm.access(...)in Separate lifecycle methods from attributes and components #2689? I say no, because that would make it so users could still have that functionality outside components.
kevinfiol, StephanHoyer, gilbert and panoply
Metadata
Metadata
Assignees
Labels
Area: CoreFor anything dealing with Mithril core itselfFor anything dealing with Mithril core itselfType: Breaking ChangeFor any feature request or suggestion that could reasonably break existing codeFor any feature request or suggestion that could reasonably break existing codeType: EnhancementFor any feature request or suggestion that isn't a bug fixFor any feature request or suggestion that isn't a bug fix
Type
Projects
Status
Completed/Declined