redux-beacon icon indicating copy to clipboard operation
redux-beacon copied to clipboard

Add notes about ensure/debounceEvent not supporting async events

Open julienma opened this issue 6 years ago • 3 comments

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • [ ] I have added tests that prove my fix is effective or that my feature works.
  • [x] I have added all necessary documentation (if appropriate)

What was done

Add a note in the docs that we don't currently support async events, cf. https://github.com/rangle/redux-beacon/issues/286#issuecomment-423023024.

Associated Issues

  • #286

:heart: Thanks

Thanks for taking the time to help out with the project, it's much appreciated :slightly_smiling_face:

julienma avatar Sep 20 '18 08:09 julienma

Thanks so much for this!

The additions to the ensure doc are perfect. But, debounceEvent actually should work with async events. If possible, could you remove those changes and just leave the additions to the ensure docs?

ttmarek avatar Sep 20 '18 23:09 ttmarek

Oh, sure.

But, what you mean is that I should be able to do this?

const emitEvent1 = debounceEvent(60*1000, emitEvent1Validated);
const emitEvent1Validated = ensure(validator,
  logEvent((action) => ({
    type: 'My Event'
  }))
);

I'm pretty sure I tried both debounceEvent(100, ensure(...)) and ensure(validator, debounceEvent(...)), and couldn't make it work any way.

I'm waiting for your confirmation before rolling back https://github.com/rangle/redux-beacon/pull/288/commits/e3dbf6421f14c5685bed89ce40e58be2d3819e15.

julienma avatar Sep 24 '18 17:09 julienma

Hmm...odd. That snippet should work. ensure will always return a plain old synchronous event definition. And the debounceEvent util should work with any plain old synchronous event definition as seen in the type definitions:

function debounceEvent(
  msDelay: number,
  eventDef: EventDefinition
): EventDefinition {
 ...
}

ttmarek avatar Sep 24 '18 23:09 ttmarek