You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the core functionality of m() is standalone function that calls the internal hyperscript directly.
This makes it really hard to extend the functionality of m(). In fact most other projects go about it by wrapping the entirety of m() and cloning all the properties (example: https://github.com/philtoms/mithril.elements )
It would be cool if m() was changed to instead call its own .m() like so:
-var m = function m() { return hyperscript.apply(this, arguments) }
var m = function m() { return m.m.apply(this, arguments) }
m.m = hyperscript
This would allow for some cool things. For example if I wanted to add a little functionality into every component in m() then such actions would be trivial to implement for someone like me.
There are also other applications, the most exciting for me would be the addition of incorporating something like registering mithril components using names instead of direct reference (for an angular-like type of managing and scaling components):
m._registeredComponents=newMap()m.register(name,component){if(m._registeredComponents.has(name))thrownewError('A previous component with that name exists');m._registeredComponents.set(name,component)}m._original=m.mm.m=function(name, ...args){returnm._original(m._registeredComponents.get(name)||name, ...args)}classHeader{view(vnode){return(<header><h1>{vnode.attrs.title}</h1></header>)}}m.register('app-header',Header)m.mount(document.body,{view: function(){return(<><app-headertitle="Hello world"/><main>Something else</main></>)}})
I have already implemented this on a local fork but it would be nice if this could be done in the core lib.
It's one extra function call that allows huge expandability (imo) for mithril :)
And like I said, I'm more than willing and happy to submit a PR with this if this is acceptable.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there.
Currently, the core functionality of
m()
is standalone function that calls the internal hyperscript directly.This makes it really hard to extend the functionality of
m()
. In fact most other projects go about it by wrapping the entirety ofm()
and cloning all the properties (example: https://github.com/philtoms/mithril.elements )It would be cool if m() was changed to instead call its own
.m()
like so:-var m = function m() { return hyperscript.apply(this, arguments) } var m = function m() { return m.m.apply(this, arguments) } m.m = hyperscript
This would allow for some cool things. For example if I wanted to add a little functionality into every component in
m()
then such actions would be trivial to implement for someone like me.There are also other applications, the most exciting for me would be the addition of incorporating something like registering mithril components using names instead of direct reference (for an angular-like type of managing and scaling components):
I have already implemented this on a local fork but it would be nice if this could be done in the core lib.
It's one extra function call that allows huge expandability (imo) for mithril :)
And like I said, I'm more than willing and happy to submit a PR with this if this is acceptable.
Beta Was this translation helpful? Give feedback.
All reactions