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

Uncaught ReferenceError: extend is not defined #36

Closed PompolutZ closed 8 years ago

PompolutZ commented 8 years ago

I get this error when I try this example:

var Student = Class(Person, { constructor: function(id, name, age) { });

extend(Student, [ Options, Events ]);

I've tried both referencing jsface and include it in the script

tnhu commented 8 years ago

extend is not exposed to global scope like Class. Could you try?

var extend = jsface.extend;

var Student = Class(Person, {
constructor: function(id, name, age) {
});

extend(Student, [ Options, Events ]);
PompolutZ commented 8 years ago

Yes, sorry I've been sloppy not to see it on my own. I've noticed that after I've posted this issue. On the other hand, why not to expose extend by default, especially if it is mentioned in tutorials?

But thanks for respond.

tnhu commented 8 years ago

Hi PompolutZ, JSFace introduces two namespaces jsface and Class to global context to minimize global namespace pollution. The other reason is to eliminate conflict with other libraries or frameworks (think if you have two libs in which both introduce extend to global context).