-
Notifications
You must be signed in to change notification settings - Fork 0
observable
awekrx edited this page May 29, 2026
·
1 revision
import { observable } from '@dev-suite/decorators/observable'
property
React to property changes via callback.
- Manual setter callback/event emission
- Repeated on-change wiring for fields
class ThemeState {
private _theme = 'light';
get theme() { return this._theme; }
set theme(next: string) {
const prev = this._theme;
this._theme = next;
this.events.emit('theme_changed', { prev, next });
}
}import { observable } from '@dev-suite/decorators/observable';
class ThemeState {
@observable(({ previousValue, value }) => events.emit('theme_changed', { previousValue, value }))
theme = 'light';
}- Centralizes cross-cutting behavior.
- Method/class/property code stays focused on domain logic.
class FormState {
private _email = '';
set email(next: string) {
this._email = next;
this.validator.schedule('email');
}
}import { observable } from '@dev-suite/decorators/observable';
class FormState {
@observable(() => validator.schedule('email'))
email = '';
}- Second scenario reuses same policy without duplication.
- Behavior is more consistent and easier to audit.