Skip to content

feat(observable): enhance event callback type specificity#10720

Merged
nativescript-oss merged 2 commits into
NativeScript:mainfrom
ArthurMJ96:feature/enhance-observable-event-types
Mar 16, 2025
Merged

feat(observable): enhance event callback type specificity#10720
nativescript-oss merged 2 commits into
NativeScript:mainfrom
ArthurMJ96:feature/enhance-observable-event-types

Conversation

@ArthurMJ96
Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

Currently, the on, off, and once methods in @nativescript/core/data/observable/index.ts use a generic EventData type for all event callbacks, regardless of the event name. This lacks type specificity, especially for "Change" events, which should use PropertyChangeData.

What is the new behavior?

This PR introduces the EndsWith utility type to dynamically determine the callback data type based on the event name. If the eventName ends with "Change", the callback will use PropertyChangeData; otherwise, it will use EventData. This provides improved type safety and developer experience.

Copy link
Copy Markdown

@nativescript-oss nativescript-oss left a comment

Choose a reason for hiding this comment

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

💯

@nativescript-oss nativescript-oss merged commit e2f9687 into NativeScript:main Mar 16, 2025
NathanWalker added a commit that referenced this pull request Mar 16, 2025
NathanWalker added a commit that referenced this pull request Mar 16, 2025
…10721)

Revert "feat(observable): enhance event callback type specificity (#10720)"

This reverts commit e2f9687.
CatchABus pushed a commit to CatchABus/NativeScript that referenced this pull request Jun 28, 2025
…ativeScript#10721)

Revert "feat(observable): enhance event callback type specificity (NativeScript#10720)"

This reverts commit e2f9687.
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