Creamel f39abb025b First late commit | 9 달 전 | |
---|---|---|
.. | ||
lib | 9 달 전 | |
LICENSE.md | 9 달 전 | |
README.md | 9 달 전 | |
package.json | 9 달 전 |
To create a mixin, subclass mixto:
Mixin = require 'mixto'
class MyMixin extends Mixin
@classMethod: -> console.log("foo")
instanceMethod: -> console.log("bar")
Then mix into classes with .includeInto
:
class MyClass
MyMixin.includeInto(this)
MyClass.classMethod()
(new MyClass).instanceMethod()
Or extend individual objects with .extend
:
myObject = {a: 1, b: 2}
MyMixin.extend(myObject)
myObject.instanceMethod()
Or build standalone instances of your 'mixin':
standalone = new MyMixin
standalone.instanceMethod()