-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
05cb3b0
commit a537f91
Showing
3 changed files
with
28 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from observ import reactive | ||
from observ.watcher import watch_effect | ||
|
||
|
||
def test_watch_effect(): | ||
state = reactive({"count": 0}) | ||
count_mirror = -1 | ||
|
||
def bump(): | ||
nonlocal count_mirror | ||
count_mirror = state["count"] | ||
|
||
watcher = watch_effect(bump, sync=True) | ||
assert watcher.lazy is False | ||
|
||
assert state["count"] == 0 | ||
assert count_mirror == 0 | ||
|
||
state["count"] = 1 | ||
|
||
assert state["count"] == 1 | ||
assert count_mirror == 1 |