vide/docs/api/strict-mode.md
Aaron Smith 68ff117be9
2023-09-12 17:55:54 +01:00

33 lines
1.1 KiB
Markdown

# Strict Mode
Strict mode is library-wide and can get set by doing:
```lua
vide.strict = true
```
Strict mode is designed to help the development process by adding safety checks
and identifying improper usage.
Currently, strict mode will:
1. Run derived sources twice a source updates.
2. Run effecters twice when a source updates.
3. Throw an error if yields occur where they are not allowed.
4. Checks for `indexes()` and `values()` returning primitive values.
5. Checks for duplicate nested properties at same depth.
6. Better error reporting and stack traces.
7. Checks for multiple `cleanup()` calls in the same function scope.
By rerunning sources and effecters, any side-effects are made more apparent.
This also helps ensure that cleanups are being handled correctly.
Accidental yielding within reactive scopes can break Vide's reactive graph,
which strict mode can catch.
As well as additional safety checks, Vide will dedicate extra resources to
recording and better emitting stack traces where errors occur, particularly
when binding properties to sources.
It is recommend to develop UI with strict mode and to disable it when pushing to
production.