Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
/ mixto Public archive

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

License

Notifications You must be signed in to change notification settings

atom/mixto

Repository files navigation

Atom and all repositories under Atom will be archived on December 15, 2022. Learn more in our official announcement

Mixto: A simple mixin superclass

CI

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()

About

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

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published