Skip to content

from reactivity.hmr.fs import *

_filters module-attribute

_filters: list[PathFilter] = []

add_filter module-attribute

add_filter = append

__all__ module-attribute

__all__ = ('notify', 'setup_fs_audithook', 'track')

PathFilter

PathFilter = Callable[[Path], bool]

fs_signals

fs_signals()
Source code in .venv/lib/python3.12/site-packages/reactivity/hmr/fs.py
@defaultdict
def fs_signals():
    return Subscribable(context=HMR_CONTEXT)

setup_fs_audithook cached

setup_fs_audithook()
Source code in .venv/lib/python3.12/site-packages/reactivity/hmr/fs.py
@cache
def setup_fs_audithook():
    @sys.addaudithook
    def _(event: str, args: tuple):
        if event == "open":
            file, _, flags = args

            if (flags % 2 == 0) and _filters and isinstance(file, str) and HMR_CONTEXT.leaf.current_computations:
                p = Path(file).resolve()
                if any(f(p) for f in _filters):
                    track(p)

track

track(file: Path)
Source code in .venv/lib/python3.12/site-packages/reactivity/hmr/fs.py
def track(file: Path):
    fs_signals[file].track()

notify

notify(file: Path)
Source code in .venv/lib/python3.12/site-packages/reactivity/hmr/fs.py
def notify(file: Path):
    fs_signals[file].notify()