Skip to content

v0.15.0

Choose a tag to compare

@mauro-andre mauro-andre released this 21 Oct 01:39
· 58 commits to main since this release
043716b

v0.15.0

This update introduces several feature enhancements, bug fixes, and improvements to the test suite, focusing on making the API more robust and user-friendly.

✨ New Features

1. Global API CuboMX.watchArrayItems

It is now possible to observe mutations in item arrays (mx-item) from anywhere in your application using the new global function CuboMX.watchArrayItems('component.array', callback). This API mirrors the functionality of the existing component-level this.$watchArrayItems, offering greater flexibility for integrations between different parts of the code.

2. New .remove(item) Method on ItemArrayProxy

To simplify list manipulation, the .remove(item) method has been added. Instead of needing to find an item's index to use .delete(index), you can now remove an item directly by passing its object reference, making the code cleaner and more declarative.

Example:

// Before
const index = this.items.indexOf(itemToRemove);
if (index > -1) {
  this.items.delete(index);
}

// Now
this.items.remove(itemToRemove);

3. New componentName Property in Item Proxies

Each item object created by the mx-item directive now includes a new metadata property: componentName. It contains the string name of the component or store that owns the array, facilitating debugging and the creation of more complex logic that depends on the item's context.

🐛 Bug Fixes & Improvements

  • Test Suite Stability: Fixed a critical issue in the test suite that caused timeouts and infinite loops, related to the interaction between asynchronous operations and the use of Vitest's fakeTimers. The affected test files were refactored to ensure stable runs.
  • Watcher Cleanup: Fixed a bug that prevented arrayWatchers from being removed from memory when a component was destroyed, preventing memory leaks.
  • Test Environment Compatibility: Resolved a ReferenceError: document is not defined that occurred in the test environment (JSDOM).
  • API Consistency: The documentation and TypeScript definitions have been updated to reflect all new features and fixes.