tnhu / jsface

Small, fast, elegant, powerful, and cross platform JavaScript OOP library. Support main(), singleton, super call, private, mixins, plugins, AOP and more.
MIT License
301 stars 46 forks source link

Introduce $class #14

Closed AntonBaukin closed 10 years ago

AntonBaukin commented 10 years ago

Please, introduce $class field in each instance created. Using it the example provided:

var Student = Class(Person, { constructor: function(id, name, age) { this.id = id; Student.$super.call(this, name, age); // Invoke parent's constructor } })

may be written as:

var api = { constructor: function(id, name, age) { this.id = id; this.$class.$super.call(this, name, age); // Invoke parent's constructor } }

var Student = Class(Person, api)

This allows to use API mixins when the real class name is not known.

tnhu commented 10 years ago

Love the great idea. I will implement $class in v2.2.0 (coming soon).

Thanks Anton!

Tan

tnhu commented 10 years ago

Fixed