8000 feat(observable): enhance event callback type specificity by ArthurMJ96 · Pull Request #10720 · NativeScript/NativeScript · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

ArthurMJ96
Copy link
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
@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
3 checks passed
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
0