Debouncing an EventSource in Halogen 5

I’m having some trouble updating a frontend app to Halogen 5. One of my previous coworkers copy/pasted this event source debouncing solution that was making its way around a few years ago:

Since the type of HalogenM and the EventSource module api changed between Halogen 4 and 5, this no longer compiles. The types also make little sense to me, and I’m not confident enough to just blindly replace this with something I think it means.

Can anyone here explain to me how to make this compatible with Halogen 5?

There is already a denounce impl

I’m not sure this really helps me because the Event type from behaviors is not really related to the Halogen EventSource module, and the only similarity here seems to be debouncing, which is a pretty widely used technique.

behaviors? No, it’s paf31/purescript-event, halogen 6 removed EventSource and replaced with Event from this lib, but paf31 deprecated original lib, and halogen staff forked it to

Event is now Emitter, and denounce is not here

I suppose You can make a pr to purescript-halogen-subscriptions and add forgotten denounce func

After that you just H.subscribe to it and stop listening with H.unsubscribe subId something like this

behaviors ? No, it’s paf31/purescript-event,

Sorry, that’s what the library was called last time I used it, I didn’t make the connection that that package was split up

EventSource and replaced with Event from this lib

Ah, I see now. I haven’t even looked at Halogen 6. Right now I’m just trying to upgrade from 4 to 5 to get this app on purescript 0.13. I’m not sure I can sanely skip this step, so it still isn’t exactly the answer I’m looking for.

Well, I’m pretty slow apparently. Apparently just replacing the type variable f :: Type -> Type with action :: Type and switching the order in some places makes it compile. I had tried doing this, but I’m not sure I caught the type variable order for EventSource which may have been the cause of my error.

Thanks everyone!