mixwith.js icon indicating copy to clipboard operation
mixwith.js copied to clipboard

Thanks for the inspiration!

Open Download opened this issue 8 years ago • 0 comments

I read your blog post and browsed this repo and it is amazing stuff you have here! I got really inspired by your work so I ran with it and created this library, loosely based on mixwith:

mics

It looks a lot like yours with some (big) differences:

  • I merged mix and mixin into one
  • with is optional syntax sugar
  • mix can return a mixin instead of a class
  • mixins can be used to instantiate an object directly
  • mix can combine multiple mixins into a new one

I found that creating an actual class is often not desirable because it limits the potential uses for the code. Instead, mics promotes the use of mixins everywhere:

import { mix, is } from 'mics'

var Looker = mix(superclass => class Looker extends superclass {
  look() {
    console.info('Looking good!')
  }
})

// directly instantiate a looker:
var looker = new Looker()
looker.look()

Thanks again for inspiring me and I'd love to get some feedback from the master!

Download avatar Apr 10 '17 20:04 Download