Need private packages and team management tools?Check out npm Teams »

mimix

0.0.2 • Public • Published

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.

Install

npm i mimix

DownloadsWeekly Downloads

0

Version

0.0.2

License

MIT

Last publish

Collaborators

  • avatar