barneycarroll / mithril-machine-tools Goto Github PK
View Code? Open in Web Editor NEWPutting the hype back in hyperscript, the OM back in virtual DOM; A bag of tricks for Mithril.
License: MIT License
Putting the hype back in hyperscript, the OM back in virtual DOM; A bag of tricks for Mithril.
License: MIT License
Difficult to read through the computed vtree and work out exactly what went wrong but I've seen { '0' : (Subtree) }
in there 🤢
The event-handler-wrapping overload inference eagerly assumes an argument, which causes the function to break when it's called directly without.
Placeholder DOM assumes some kind of manual manipulation is necessary to inject content on the second draw, but Island hands this off to Mithril render core — placeholder can consist of a nullish vnode.
How hard can it be?
Waiter is cumbersome because it requires isolating a single detachment point - the Waiter - to trigger descendant Services. Other compound components are not so sensitive to the exact logical position of their controller component, and positioning Waiter in the correct position becomes an irritatingly subtle task. Additionally, it is impossible to indicate that a Serviced node be subject to the detachment condition of multiple nodes:
condition1 &&
m(Waiter, Service1 =>
m('.Page',
m(Content),
m(Comments),
condition2 &&
m(Waiter, Service2 =>
m(Editor,
condition3 &&
// Service1 or Service2 will foreclose the other;
// Defaulting on condition3 triggers neither (should it?)
)
)
)
)
Service logic is thus fudged inasmuch as it shadows onbeforeremove logic for its immediate children, but only on the condition of one uniquely positioned Waiters removal.
A more straightforwardly usable removal mechanism would be to employ the logic of Mobile -> Unit such that Waiter registers Service instances on every view execution, and triggers onbeforeremove logic for all newly departed Services. Thereby:
m(Waiter, Service =>
condition1 &&
m('.Page',
m(Content),
m(Comments),
condition2 &&
m(Editor,
condition3 &&
m(Service, {key: 'modal'}
m(Modal)
)
)
)
)
With the new logic, Services' key communicates the deferred removal condition, rather than the position of its Waiter controller.
Mobile Unit could be extended with a transition hook that stretched over the period before and after DOM movement to control the transition.
A generator would be useful for yielding to the point of movement and resuming thereafter. Here follows pseudo-code example tweening the element between its initial & eventual positions:
const fixed = {position: 'fixed'}
m(Unit, {
*transition({dom, move}){
const initial = dom.getBoundingClientRect()
yield move
// dom is now in its new position
const eventual = dom.getBoundingClientRect()
dom.animate([
{…fixed, initial },
{…fixed, eventual},
], options)
}
},
m(Video)
)
🤔
Until you get the time to write real docs, it would be nice to add flems links in the README with sample usage.
Are we going with opponents
? It'd be nice to start using proponents in real projects even though it is exploratory.
Please take pity on us poor lowly creatures.
Current logic dictates that prior content is trashed and new content initialised from scratch on every draw (if the outlet appears before the corresponding inlet).
A more elegant solution would be to perform all traversals from the top down, complementing #8
Can't import { Liminal } from 'mithril-machine-tools'
, needs to be exported
I’ve tried to write docs for this so many times but each API is kind of its own elaborate story. I may blog about these later but to be able to draw a line under a feature-complete v1 I need to put up documentation that reasonably demonstrates usage.
I’m currently thinking of doing these for every export:
Should be its own thing really, what with having external dependencies and involved use case requirements.
In the mithril docs we've decided that pojo's should only be used for stateless components, closures for stateful.
Seeing as the justification for Inline is to have some state inline. It seems we could take that as an opportunity to only support closures.
What do you think?
I use tailwind, so it's useful to add multiple classes like this:
m(Liminal, {
present: "transition duration-300",
entry: "opacity-100",
exit: "opacity-0",
}, ...)
However this throws the standard browser error:
InvalidCharacterError: The string contains invalid characters.
on a dom.classList.add
line.
In this example the 'chat' contents should move seamlessly, but it's recreated every time.
Follow up: MithrilJS/mithril.js#2135
Because of nested fragments, components immediately returning components, etc, etc, Island needs to account for the fact that its nearest DOM-matched ancestor may be several vnodes away. We cater for this by creating a clone of the 'host' vnode entity and creating a hot path down to the recomputed Island view.
But seeing as we have to tunnel through any number of intervening vnodes anyway, would we be better off avoiding the intermediate host
entity and simply rendering the patched structure to the original root?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.