client: allow replacing event handler (eg. during onInit())

This commit is contained in:
Michael Davidsaver
2021-01-02 15:05:27 -08:00
parent 3dd4dd6a66
commit db32f05ce1
2 changed files with 12 additions and 0 deletions
+8
View File
@@ -177,6 +177,14 @@ struct SubscriptionImpl : public OperationBase, public Subscription
return std::shared_ptr<Subscription>(self);
}
virtual void onEvent(std::function<void(Subscription&)>&& fn) override final {
decltype (event) junk;
loop.call([this, &junk, &fn]() {
junk = std::move(event);
this->event = std::move(fn);
});
}
virtual bool cancel() override final {
decltype (event) junk;
bool ret;