revery-ui / revery

:zap: Native, high-performance, cross-platform desktop apps - built with Reason!
https://www.outrunlabs.com/revery/
MIT License
8.06k stars 196 forks source link

fix(hooks): tick callback staleness #986

Closed glennsl closed 4 years ago

glennsl commented 4 years ago

As reported by @lessp on Discord, this fixes an issue where the tick hook would always execute the initial callback instead of updating with the latest given to it. The fix is to store the callback in a ref, and call that instead of calling the closed over callback directly.

Technically this is a breaking change for code relying on the behavior that the callback goes stale. That seems highly unlikely though, at least intentionally.