Appearance
Reusable Reactive Behavior Rules
These rules define when frontend behavior should be reusable, how it owns state and lifecycle, and how it relates to services and shared stores. The decisions apply across frameworks. Vue composables are used as concrete examples of reusable reactive behavior.
Status
Accepted
Rules
- Create reusable behavior around meaningful responsibilities defines when behavior extraction is useful and how it differs from local logic.
- Choose between a service and reactive behavior defines the decision tree for selecting the correct abstraction.
- Keep behavior state scoped and inputs reactive defines instance scope, reactive inputs, and escalation to shared state.
- Compose lifecycle and reactive behavior defines side-effect ownership, cleanup, and composition.
- Use explicit reusable-behavior APIs defines naming, return values, fetching boundaries, and stateless utilities.
- Test reusable behavior at its public boundary defines tests and the main service, store, and behavior-module anti-patterns.
Core Principle
A reusable reactive behavior module owns framework-dependent state, lifecycle, and side effects. In Vue, this is commonly a composable using refs, computed values, watchers, and lifecycle hooks. It MUST NOT replace a service or a shared state store.
Architecture at a Glance
text
View or business component
|
+--> Local framework state
|
+--> Reusable reactive behavior (Vue: composable)
| reactive behavior, lifecycle, side effects
| |
| v
| Business service
| business rules, API, mapping
| |
| v
| API
|
`--> Shared store (Vue: Pinia)
shared reactive state and lifecycle
|
v
Business serviceRelated Rules
- Frontend application structure
- Reactivity management
- Services management
- Testing strategy
- Component services, reactivity, and testability