sample-payment-frame icon indicating copy to clipboard operation
sample-payment-frame copied to clipboard

Remove specific event handlers

Open brandonburkett opened this issue 6 years ago • 1 comments

It would be cool if we could optionally pass in the name of the event listener we wanted to clear / remove. EX: Spreedly.removeHandlers('validation')

Thanks

brandonburkett avatar May 16 '19 13:05 brandonburkett

I'd also appreciate this functionality - I have different events/flows handled in separate React hooks and it would be nice to have some granularity in removing tokenization handlers without removing consoleError handling, for example.

In case multiple handlers are listening to a single event (i.e. recache validation vs tokenization validation) I would suggest maybe a setup similar to setTimeout/clearTimeout:

useEffect(() => {
  const handlerId = Spreedly.on('validation', () => {});

  return => {
    Spreedly.removeHandler(handlerId);
  };
}, []);

mikemeyerson avatar Apr 14 '21 22:04 mikemeyerson