Skip to content

Conversation

@trusktr
Copy link
Member

@trusktr trusktr commented Dec 14, 2025

Features:

  • A new @effect decorator has been added to create reactive effects based on signals and memos. Use @effect on methods to automatically run them when their dependencies change.
  • Introduced a metadata shim until native support is available, and used metadata to refactored decorators to simplify initialization and finalization processes.
  • Added tests for invalid usages, and for subclassing behavior for all decorators.
  • Updated signalify to apply batch() so that if a signal setter writes to a superclass signal, it doesn't cause multiple updates.
  • Improved overall type definitions and metadata management for better clarity and maintainability.

BREAKING: Updated the @memo decorator to remove support for usage on class fields.

  • migration: @memo foo = () => a() + b() should be changed to @memo get foo() { return a() + b(); }

Features:

- A new `@effect` decorator has been added to create reactive effects based on signals and memos. Use `@effect` on methods to automatically run them when their dependencies change.
- Introduced a metadata shim until native support is available, and used metadata to refactored decorators to simplify initialization and finalization processes.
- Added tests for invalid usages, and for subclassing behavior for all decorators.
- Updated signalify to apply `batch()` so that if a signal setter writes to a superclass signal, it doesn't cause multiple updates.
- Improved overall type definitions and metadata management for better clarity and maintainability.

BREAKING: Updated the `@memo` decorator to remove support for usage on class fields.
  - migration: `@memo foo = () => a() + b()` should be changed to `@memo get foo() { return a() + b(); }`
Copilot AI review requested due to automatic review settings December 14, 2025 09:11
@trusktr trusktr merged commit ac60aff into main Dec 14, 2025
6 checks passed
@trusktr trusktr deleted the effect-decorator branch December 14, 2025 09:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new @effect decorator for creating reactive effects declaratively on class methods, alongside significant refactoring of the decorator infrastructure to use metadata for improved initialization ordering. The changes include a metadata shim for decorator support, refactored memo/signal decorators, and performance improvements using batch() to prevent multiple effect runs.

Key Changes:

  • New @effect decorator for declaring reactive effects on methods and auto-accessors
  • Metadata-based decorator initialization system replacing the previous approach
  • Breaking change: @memo no longer supports class fields (must use getters/methods/accessors)

Reviewed changes

Copilot reviewed 24 out of 95 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/decorators/effect.ts New @effect decorator implementation with startEffects/stopEffects helpers
src/decorators/metadata-shim.ts Polyfill for Symbol.metadata until native support
src/_state.ts Refactored member tracking using metadata with custom initialization order
src/decorators/types.ts Updated type definitions for metadata-based system
src/decorators/signal.ts Added batch() to setters, refactored to use metadata system
src/decorators/memo.ts Removed field support (breaking), refactored to metadata system
src/signals/signalify.ts Wrapped setter logic in batch() to prevent multiple effect runs
src/signals/memoify.ts Added member stat parameter, improved error handling
src/mixins/Effectful.ts Major refactor with startEffects/clearEffects, improved lifecycle
src/decorators/effect.test.ts Comprehensive tests for @effect decorator
src/mixins/Effectful.test.ts New test file for Effectful mixin
src/decorators/signal.test.ts Added subclassing and invalid usage tests
src/decorators/memo.test.ts Updated tests for breaking changes, added subclassing tests
src/index.test.ts Added custom element test classes
src/example.ts Updated example to demonstrate @effect usage
src/decorators/component.ts Added ref support and improved lifecycle

The implementation is well-tested with comprehensive coverage of edge cases, invalid usages, and subclassing behavior. The breaking change to @memo is clearly documented with migration guidance.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants