mixto

A mixin superclass. Its subclasses have `.extend` and `.includeInto` methods to mix behavior into other objects and classes.

  • mixto

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
mixto
1531.0.09 years ago9 years agoMinified + gzip package size for mixto in KB

Readme

Mixto: A simple mixin superclass Build Status
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:
```coffee-script myObject = {a: 1, b: 2} MyMixin.extend(myObject) myObject.instanceMethod()
Or build standalone instances of your 'mixin':
standalone = new MyMixin standalone.instanceMethod() ```