From a511d2d1ef5fa07dde601961fe9394b474aad5ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 24 Apr 2021 21:20:25 +0200 Subject: Behavior lens for shared refs from local state --- include/erebos/frp.h | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'include/erebos/frp.h') diff --git a/include/erebos/frp.h b/include/erebos/frp.h index 587d2b6..b60b29f 100644 --- a/include/erebos/frp.h +++ b/include/erebos/frp.h @@ -4,7 +4,6 @@ #include #include #include -#include #include #include @@ -115,6 +114,8 @@ public: return impl->get(ctime, x); } + template BhvFun lens() const; + const shared_ptr> impl; }; @@ -135,6 +136,8 @@ public: } Watched watch(function); + template BhvFun lens() const; + const shared_ptr> impl; }; @@ -227,4 +230,27 @@ BhvFun operator>>(const BhvFun & f, const BhvFun & g) return impl; } + +template +class BhvLens : public BhvImpl +{ +public: + B get(const BhvCurTime &, const A & x) const override + { return A::template lens(x); } +}; + +template +template +BhvFun BhvFun::lens() const +{ + return *this >> BhvFun(make_shared>()); +} + +template +template +BhvFun BhvFun::lens() const +{ + return *this >> BhvFun(make_shared>()); +} + } -- cgit v1.2.3