From 00e52ec8ee38a85737c093d90ebfba5069829608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 8 May 2021 18:37:07 +0200 Subject: FRP: run callback when starting to watch behavior --- include/erebos/frp.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'include/erebos/frp.h') diff --git a/include/erebos/frp.h b/include/erebos/frp.h index 8014536..681aee8 100644 --- a/include/erebos/frp.h +++ b/include/erebos/frp.h @@ -160,11 +160,18 @@ using Bhv = BhvFun; template Watched Bhv::watch(function f) { + BhvCurTime ctime; + auto & impl = BhvFun::impl; + if (impl->needsUpdate(ctime)) + impl->doUpdate(ctime); + auto cb = make_shared>( [impl = BhvFun::impl, f] (const BhvCurTime & ctime) { f(impl->get(ctime, monostate())); }); - BhvFun::impl->watchers.push_back(cb); + + impl->watchers.push_back(cb); + f(impl->get(ctime, monostate())); return Watched(move(cb)); } -- cgit v1.2.3