Skip to content

barneycarroll/mimix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

mimix

A mithril mixin mixer.

mimix( [ mixin1, mixin2, etc ] ) is like { ...mixin1, ...mixin2, ...etc }, but geared towards the semantics of Mithril virtual DOM nodes (vnodes), DOM properties, and lifecycle methods. The goal is to enable a form of behaviour composition more subtle than components, by allowing mixins describing vnode behaviour to be composed into a singular node.

When multiple mixins share a key:

  1. Multiple functions are bound into one which executes all of these with the same input context & arguments:
  2. if all return false, false is passed on (ideal for onbeforeupdate)
  3. if any return a Promise, then the consuming context receives a Promise.all of all return values (ideal for onbeforeremove)
  4. otherwise the last such function's output is passed through
  5. Arrays are concatenated (ideal for children)
  6. Non-null Objects are merged into a new object (ideal for style)
  7. class / className entries are space separated

In all other cases, it behaves like a traditional object merge would and subsequent values override the previous.

About

Composable Mithril mixin factory

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published