postaljs / postal.js

JavaScript pub/sub library supporting advanced subscription features, and several helpful add-ons.

Home Page:http://ifandelse.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

postal publish (invokeSubscriber) sets undefined for 'this' unless the prototype context is used

robvon opened this issue · comments

I have patched v1.0 7 at line 169 as below in my source:

...
168: var len = pipeline.length;
169: var context = self._context || self; // <<<<<< -----see the '|| self'
170: var idx = -1;
...
This gives the receiver full access to the Sub Defn which can then be modified with extra run time stuff if required (as I do). Either way, the invocation currently sets the context (this) to undefined by default.
I can get the same result with some closure tricks but setting 'this' seems quite neat.

Regards

Rob