Add always_update as a parameter for a var reactive

Redux. I managed to commit the wrong thing last time; although it was using
this and this was done for that.
This commit is contained in:
Dave Pearson
2023-05-04 14:17:20 +01:00
parent f6da3e9fb2
commit 10e61987e3

View File

@@ -76,11 +76,13 @@ class Reactive(Generic[ReactiveType]):
def var(
cls,
default: ReactiveType | Callable[[], ReactiveType],
always_update: bool = False,
) -> Reactive:
"""A reactive variable that doesn't update or layout.
Args:
default: A default value or callable that returns a default.
always_update: Call watchers even when the new value equals the old value.
Returns:
A Reactive descriptor.
@@ -326,18 +328,21 @@ class var(Reactive[ReactiveType]):
Args:
default: A default value or callable that returns a default.
init: Call watchers on initialize (post mount).
always_update: Call watchers even when the new value equals the old value.
"""
def __init__(
self,
default: ReactiveType | Callable[[], ReactiveType],
init: bool = True,
always_update: bool = False,
) -> None:
super().__init__(
default,
layout=False,
repaint=False,
init=init,
always_update=always_update,
)