UNPKG

@magnusbag/livets-core

Version:

TypeScript API layer for LiveTS framework

57 lines 1.61 kB
"use strict"; /** * Decorators for LiveTS components */ Object.defineProperty(exports, "__esModule", { value: true }); exports.Event = Event; exports.Lifecycle = Lifecycle; exports.State = State; exports.Computed = Computed; /** * Decorator for marking methods as event handlers */ function Event(eventName) { return function (target, propertyKey, descriptor) { // Store event handler metadata if (!target._eventHandlers) { target._eventHandlers = new Map(); } target._eventHandlers.set(eventName, descriptor.value); }; } /** * Decorator for marking methods as lifecycle hooks */ function Lifecycle(hook) { return function (target, propertyKey, descriptor) { // Validate that the method name matches the hook if (propertyKey !== hook) { throw new Error(`Lifecycle decorator '${hook}' can only be used on method '${hook}'`); } }; } /** * Decorator for component state properties */ function State() { return function (target, propertyKey) { // Store state property metadata if (!target._stateProperties) { target._stateProperties = new Set(); } target._stateProperties.add(propertyKey); }; } /** * Decorator for computed properties */ function Computed() { return function (target, propertyKey, descriptor) { // Mark as computed property if (!target._computedProperties) { target._computedProperties = new Set(); } target._computedProperties.add(propertyKey); }; } //# sourceMappingURL=decorators.js.map