fcts needs to be on instances, not prototype
isaacs opened this issue · comments
Since fcts is on the prototype, and an object, it's shared by all instances of the same emitter class.
function Foo () {}
MicroEvent.mixin(Foo)
f = new Foo
b = new Foo
f.bind("blerg", function () { console.log("f got blerg") })
b.trigger("blerg")
Instead of putting fcts on the prototype, you must check for it on the object at the start of the bind/trigger/unbind functions and default it to {}
if it's not set or not an object.
it should fix it, what do you think ?
On Wed, Mar 23, 2011 at 4:26 PM, isaacs <
reply@reply.github.com>wrote:
Since fcts is on the prototype, and an object, it's shared by all instances
of the same emitter class.function Foo () {}
MicroEvent.mixin(Foo)
f = new Foo
b = new Foo
f.bind("blerg", function () { console.log("f got blerg") })
b.trigger("blerg")Instead of putting fcts on the prototype, you must check for it on the
object at the start of the bind/trigger/unbind functions and default it to
{}
if it's not set or not an object.Reply to this email directly or view it on GitHub:
#1
Yeah, that should do it.
You might want to make sure that typeof this.fcts === 'object'
so
that you don't end up trying to set a property on a 7 or something.
On Wed, Mar 23, 2011 at 08:39, jeromeetienne
reply@reply.github.com
wrote:
it should fix it, what do you think ?
On Wed, Mar 23, 2011 at 4:26 PM, isaacs <
reply@reply.github.com>wrote:Since fcts is on the prototype, and an object, it's shared by all instances
of the same emitter class.function Foo () {}
MicroEvent.mixin(Foo)
f = new Foo
b = new Foo
f.bind("blerg", function () { console.log("f got blerg") })
b.trigger("blerg")Instead of putting fcts on the prototype, you must check for it on the
object at the start of the bind/trigger/unbind functions and default it to
{}
if it's not set or not an object.Reply to this email directly or view it on GitHub:
#1Reply to this email directly or view it on GitHub:
#1 (comment)