DracoBlue/jsb

whenFired for all past events

larslaade opened this issue · 5 comments

Currently jsb saves only the last event for whenFired. In my use-case i need all past events.

the setup:

I have two modules of the same kind:

<div class="jsb_ jsb_module" data-jsb="{"id":"foo-1"}"> ... </div>
...
<div class="jsb_ jsb_module" data-jsb="{"id":"foo-2"}"> ... </div>

fire before the modules are loaded events:

jsb.fireEvent('module::disable', {id: 'foo-1'});
jsb.fireEvent('module::disable', {id: 'foo-2'});

the module code has:

jsb.whenFired('module::disable', {id: this.id});

result: only the second event with id 'foo-2' fired
expected: both are fired

Is it possible to get all past events?

No ;(.

  1. Can you fire an event like: "module::status" and all disabled modules
    retrigger the "modules::disable" or "modules::enable" instead?
  2. Another workaround could be to trigger "modules::disable::12355" (some
    ID) and listen on a regexp like: /midules::disable::/? (with jsb 2.0 it
    will trigger only once on regexp with whenfired, but I could fix that.

Anyways the first way is 100% the prefered way ;)

Am Dienstag, 7. Juli 2015 schrieb Lars Laade :

Currently jsb saves only the last event for whenFired. In my use-case i
need all past events.

the setup:

I have two modules of the same kind:

...

...

...

fire before the modules are loaded events:

jsb.fireEvent('module::disable', {id: 'foo-1'});
jsb.fireEvent('module::disable', {id: 'foo-2'});

the module code has:

jsb.whenFired('module::disable', {id: this.id});

result: only the second event with id 'foo-2' fired
expected: both are fired

Is it possible to get all past events?


Reply to this email directly or view it on GitHub
#23.

http://dracoblue.net

ok, thank you anyway... i take the first way :)

@larslaade please see #24 and the bugfix release in 2.0.1.

There was an issue with fireing and using whenFired in this case (if you use filtervalues). Rare Usecase, but looks similar to yours!

Sorry, but 2.0.1 does not fix my problem.
There is a typo with the versionnumber in jsb.js line 2 (2.1.0 instead of 2.0.1).

We added jsb.fireStickyEvent in jsb 2.3.0. THis should resolve your ticket, doesn't it?