Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

A better way to call an async function inside an event handler

$
0
0

I have this utility function in my project:

// Turn async function into a fire-and-forget function
let prime: ('a => promise<unit>) => 'a => unit = f => x => f(x)->ignore

With that, I would handle this by wrapping the handler with it:

let handleDuplicateQuote = prime(async _ => ...)

then I can just use it like a normal event handler:

onClick=handleDuplicateQuote

Viewing all articles
Browse latest Browse all 2592

Trending Articles