Vibe.d timer - change callback?
James Blachly
james.blachly at gmail.com
Thu Aug 27 18:51:58 UTC 2020
On Tuesday, 25 August 2020 at 18:42:53 UTC, codic wrote:
> I'd like to be able to change the callback of a vibe.d Timer
> (eg created with
> http://vibe-core.dpldocs.info/v1.9.3/vibe.core.core.createTimer.html) after creation, something like:
>
> auto timer = createTimer();
> timer.rearm(duration, /*...*/);
> timer.callback = delegate {
> // things
> }
Would creating a dynamic redirection function as delegate serve
your purpose?
https://dlang.org/library/std/functional/to_delegate.html
You can also pass object having `opCall` to `to_delegate` and th
is could also provide dynamic dispatch.
More information about the Digitalmars-d-learn
mailing list