Connecting Services to UI Frameworks (View Layer Integration)
A core architectural principle of @pravosleva/reactive-engine v3.0.1 is the complete decoupling of business logic and the reactive state graph (signal, computed, resource, AbstractService) from any specific rendering framework.
The exact same service layer can power React, Vue 3, Angular, or Vanilla DOM applications simultaneously without rewriting domain logic or unit tests.
Unified Integration Blueprint
Regardless of the UI framework you choose, connecting components to the reactive core follows a consistent three-step pattern:
- Encapsulate domain logic in
AbstractService: Components do not manage complex fetching, caching, or validation workflows—they simply resolve a service instance viaengine.inject(MyService). - Fine-grained view subscriptions: Each UI component subscribes strictly to the signals and computed properties it actually renders (via
useSyncExternalStorein React,shallowRef/ adapters in Vue, orengine.effectin Vanilla JS). - Command-driven mutations: User interactions (clicks, text input, form submissions) delegate back to the service by invoking its public methods (
service.submit(),service.toggleTodo(id)).
Framework-Specific Integration Guides
Detailed setup instructions, ready-to-use hooks/composables, and rendering optimization tips for each platform are available in the Quick Start guides:
- Angular 20+ Integration — bridging core signals, computed values, and Proxy collections into Angular Signals via
toAngularSignalwith automaticDestroyRefcleanup. - React 18+ Integration — subscribing components via
engine.use()anduseReactiveValuebuilt on nativeuseSyncExternalStorewith zero redundant re-renders. - Vue 3.2+ Integration — binding core primitives to
ShallowRefviaengine.use()/useReactiveValuewith automaticonScopeDisposeteardown. - Vanilla JS & Direct DOM — wiring
engine.effect()callbacks and async resources directly to native DOM nodes without a Virtual DOM.
Architectural Best Practices for the View Layer
- Provide
ReactiveEnginevia Context or component-tree DI: Avoid hardcoding components against a global module singleton when building SSR apps or rendering multiple isolated widget trees on the same page (see Multi-Instance Isolation & Cross-Engine Bridges). - Avoid mirroring service state in local component state: When data already lives inside
service.items.valueorservice.form, avoid copying it intouseStateor localrefs unless strictly needed for transient UI state—keep a single source of truth inside your services.