diff --git a/client/src/meson.build b/client/src/meson.build index 07a6e94..c4d5227 100644 --- a/client/src/meson.build +++ b/client/src/meson.build @@ -19,6 +19,7 @@ lib = library( 'der.vala', 'main_window.vala', 'periodic.vala', + 'refresher.vala', 'request.vala', 'response.vala', 'session_manager.vala', diff --git a/client/src/refresher.vala b/client/src/refresher.vala new file mode 100644 index 0000000..12e48f6 --- /dev/null +++ b/client/src/refresher.vala @@ -0,0 +1,23 @@ +namespace StudySystemClient { + public interface IRefreshable { + public abstract async void refresh(); + } + + private class Refresher : Periodic { + private weak IRefreshable target; + + public Refresher(IRefreshable target, uint period_ms) { + base(period_ms); + this.target = target; + } + + protected override void task() { + if (target != null) { + Idle.add(() => { + target.refresh.begin(); + return false; + }); + } + } + } +}