]> git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/ex-mode/node_modules/event-kit/node_modules/grim/node_modules/emissary/node_modules/mixto/README.md
7c450e3ec04572326f91ecf4c82f0f1e2088f51e
[rbdr/dotfiles] / atom / packages / ex-mode / node_modules / event-kit / node_modules / grim / node_modules / emissary / node_modules / mixto / README.md
1 # Mixto: A simple mixin superclass [![Build Status](https://travis-ci.org/atom/mixto.png?branch=master)](https://travis-ci.org/atom/mixto)
2
3 To create a mixin, subclass mixto:
4
5 ```coffee
6 Mixin = require 'mixto'
7
8 class MyMixin extends Mixin
9 @classMethod: -> console.log("foo")
10 instanceMethod: -> console.log("bar")
11 ```
12
13 Then mix into classes with `.includeInto`:
14
15 ```coffee
16 class MyClass
17 MyMixin.includeInto(this)
18
19 MyClass.classMethod()
20 (new MyClass).instanceMethod()
21 ```
22
23 Or extend individual objects with `.extend`:
24
25 ```coffee-script
26 myObject = {a: 1, b: 2}
27 MyMixin.extend(myObject)
28 myObject.instanceMethod()
29 ```
30
31 Or build standalone instances of your 'mixin':
32
33 ```
34 standalone = new MyMixin
35 standalone.instanceMethod()
36 ```