sample-payment-frame
sample-payment-frame copied to clipboard
Remove specific event handlers
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
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);
};
}, []);