You got it. That interface is exactly what I'd suggest. You're still passing in the function, just with one level of indirection. It's a bit more verbose, but not too bad, I think. Nice work!
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.