DioxusLabs / DioxusLabs/dioxus

Inconsistent Reactivity Terminology

Open
#3,512 0 comments 0 reactions 0 assignees View on GitHub
documentation tweak
Dominant language
Rust
Stars
39.1k
Forks
1.9k
Avg merge
4d 10h
Merged PRs (30d)
4

Description

# Reactive Terminology

When referencing reactivity in the guide and inline docs, we haven't been very consistent with terminology. Recently I have been trying to switch to using two different terms for values in reactive code:

1) Tracked values are values that track when they have been read. They will add themselves as dependencies to reactive hooks and automatically rerun any reactive hooks that subscribe to them when they are changed. Eg. `Signal`, `ReadOnlySignal`, `Memo`, and `Resource` are all tracked values, but `Effect` is not

- Solid JS calls these reactive values. https://docs.solidjs.com/concepts/signals#reactivity
- Vue calls these reactive objects. https://vuejs.org/guide/scaling-up/state-management.html#simple-state-management-with-reactivity-api
- Svelte calls this reactive state
- Leptos calls these reactive values
- React calls these reactive values

2) Reactive hooks are hooks that keep track of dependencies and rerun when the tracked values that are read inside of them change. Eg. `use_memo`, `use_resource`, and `use_effect` are all reactive hooks, but `use_signal` is not

- Solid JS calls these tracking scopes. https://docs.solidjs.com/concepts/signals#reactivity
- Vue calls these reactive effects. https://vuejs.org/guide/extras/reactivity-in-depth.html#how-reactivity-works-in-vue
- Svelte mentions effects and derived state, but I don't see a central term for all of these kinds of functions
- Leptos calls these reactive closures

It might make sense to switch the two since that seems to align more closely with other frameworks people could be familiar with

Places where we refer to *tracked* values as *reactive* today:
- https://dioxuslabs.com/learn/0.6/cookbook/antipatterns#avoid-interior-mutability-in-props
- https://dioxuslabs.com/learn/0.6/essentials/state/#making-props-reactive
- https://github.com/DioxusLabs/dioxus/blob/19ca7075d6349acc481d6e4115019429c1ed4307/packages/core-macro/docs/props.md?plain=1#L238
- https://github.com/DioxusLabs/dioxus/blob/19ca7075d6349acc481d6e4115019429c1ed4307/packages/hooks/docs/use_resource.md?plain=1#L112
- https://github.com/DioxusLabs/dioxus/blob/19ca7075d6349acc481d6e4115019429c1ed4307/packages/hooks/docs/derived_state.md?plain=1#L63
- https://github.com/DioxusLabs/dioxus/blob/19ca7075d6349acc481d6e4115019429c1ed4307/packages/core-macro/docs/component.md?plain=1#L225
- https://github.com/DioxusLabs/dioxus/blob/19ca7075d6349acc481d6e4115019429c1ed4307/packages/core/docs/reactivity.md?plain=1#L67
- https://github.com/DioxusLabs/dioxus/blob/19ca7075d6349acc481d6e4115019429c1ed4307/packages/hooks/src/use_reactive.rs#L103

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.