Commit Graph

21 Commits

Author SHA1 Message Date
Dave Pearson
fa47d0bd41 Mark the public/private validate and compute tests as xfails 2023-05-25 15:27:27 +01:00
Dave Pearson
bd6717f3d5 Add a test for public and private computes
This fails for now.
2023-05-25 15:23:33 +01:00
Dave Pearson
abda34aa13 Add a test for private validation
Currently failing.
2023-05-25 11:48:04 +01:00
Will McGugan
83b1fcc102 raise attribute error (#2443)
* raise attribute error

* fix compute defaults
2023-05-01 16:57:40 +01:00
Dave Pearson
54db445dd7 Change private watcher support call public and private if available
See https://github.com/Textualize/textual/pull/2442#issuecomment-1529512891

This changes the original PR so that, rather than calling a private watcher
instead of a public, as originally issued, we now call public and private,
if they're both there.

If they are both there private is called first.
2023-05-01 10:28:55 +01:00
Dave Pearson
847fd6e69e Add support for private watch methods
This change allows for private watch methods. By convention they start with
an underscore. If a reactive or var has a private watch method, it will be
used in preference to a public watch method.

With this change it becomes easier to have a private reactive/var whose
watcher is also private. For example:

    _counter = var(0)
    """This is a private counter, it won't appear in the docs."

    ...

    def _watch__counter(self) -> None:
        """Watch _counter, but don't appear in the docs either."
        ...

See #2382.
2023-05-01 10:01:50 +01:00
Will McGugan
52e522b2e8 test 2023-02-19 22:26:07 +00:00
Will McGugan
d18c794e69 call compute on demand 2023-02-19 22:24:28 +00:00
Darren Burns
9287f64a66 Add isort pre-commit hook, sort imports in src and test directories 2023-02-09 13:28:08 +00:00
Darren Burns
92ccf84496 Some updates to test_reactive 2023-01-16 11:06:13 +00:00
Darren Burns
fa1f33ff64 Remove a sleep that is no longer required in reactive test 2023-01-16 11:02:38 +00:00
Will McGugan
6063b0c9b2 remove comment [skip ci] 2023-01-13 21:17:19 +00:00
Will McGugan
6af2b61fc7 watching computed 2023-01-13 20:56:33 +00:00
Will McGugan
c3129c8331 fix inheritance 2023-01-13 17:22:52 +00:00
Will McGugan
8f0f0d8c12 refactor 2023-01-13 10:44:13 +00:00
Will McGugan
027635b978 merge 2023-01-12 17:45:36 +00:00
darrenburns
af8af1bee9 Ensure watcher isn't called on first_set when init is False and value doesn't change (#1367)
* Ensure watcher not called when value doesnt change, even on first set

* Update CHANGELOG.md
2022-12-20 11:17:11 +00:00
Darren Burns
2b8b7c15e6 Add extra test for validator called before dom ready, update changelog 2022-12-14 12:09:00 +00:00
Darren Burns
591b692720 Call validator on first set 2022-12-14 11:28:10 +00:00
darrenburns
e968ca0e50 Various tests for reactivity (#1223) 2022-11-18 19:40:30 +00:00
Will McGugan
dd5c0e612a make watchers instant 2022-11-09 12:06:14 +00:00