From a5f4c2d90b9afaacd9af9b09cc954f3a5758388b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Piaggio?= Date: Tue, 16 Jul 2024 08:19:04 -0300 Subject: [PATCH] more specific types for ref async extensions --- .../main/scala/crystal/react/syntax/effect.scala | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/core/js/src/main/scala/crystal/react/syntax/effect.scala b/modules/core/js/src/main/scala/crystal/react/syntax/effect.scala index b97b9300..67311455 100644 --- a/modules/core/js/src/main/scala/crystal/react/syntax/effect.scala +++ b/modules/core/js/src/main/scala/crystal/react/syntax/effect.scala @@ -118,13 +118,17 @@ trait effect { inline def modStateAsync(f: S => S): Reusable[DefaultA[Unit]] = self.modState(f).map(_.to[DefaultA]) - extension [A](self: Hooks.UseRef[A]) - inline def setIn[F[_]: Sync](a: A): F[Unit] = self.set(a).to[F] + extension [A](self: NonEmptyRef.Get[A]) + inline def getIn[F[_]: Sync]: F[A] = self.get.to[F] + inline def getAsync: DefaultA[A] = getIn[DefaultA] + + extension [A](self: NonEmptyRef.Set[A]) + inline def setIn[F[_]: Sync](a: A): F[Unit] = self.set(a).to[F] + inline def setAsync: A => DefaultA[Unit] = setIn[DefaultA](_) + + extension [A](self: NonEmptyRef.Simple[A]) inline def modIn[F[_]: Sync](f: A => A): F[Unit] = self.mod(f).to[F] - inline def getIn[F[_]: Sync]: F[A] = self.get.to[F] - inline def setAsync: A => DefaultA[Unit] = setIn[DefaultA](_) inline def modAsync: (A => A) => DefaultA[Unit] = modIn[DefaultA](_) - inline def getAsync: DefaultA[A] = getIn[DefaultA] extension [S](self: UseSerialState[S]) inline def setStateAsync: Reusable[S => DefaultA[Unit]] =