Skip to content
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

refactor(switch): signal migration #468

Merged
merged 3 commits into from
Nov 12, 2024
Merged

refactor(switch): signal migration #468

merged 3 commits into from
Nov 12, 2024

Conversation

ashley-hunter
Copy link
Collaborator

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Which package are you modifying?

  • accordion
  • alert
  • alert-dialog
  • aspect-ratio
  • avatar
  • badge
  • button
  • calendar
  • card
  • checkbox
  • collapsible
  • combobox
  • command
  • context-menu
  • data-table
  • date-picker
  • dialog
  • dropdown-menu
  • hover-card
  • icon
  • input
  • label
  • menubar
  • navigation-menu
  • pagination
  • popover
  • progress
  • radio-group
  • scroll-area
  • select
  • separator
  • sheet
  • skeleton
  • slider
  • sonner
  • spinner
  • switch
  • table
  • tabs
  • textarea
  • toast
  • toggle
  • tooltip
  • typography

What is the current behavior?

Closes #438

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@@ -58,5 +58,5 @@ export function rxHostPressedListener() {
}),
filter(Boolean),
),
).pipe(debounceTime(0));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was causing several issues. The individual listeners attached in the lines above already have a delay, the problem is that this delay is added after the takeUntilDestroyed, which means that if the checkbox is destroyed during this debounce we get an error thrown. This was resulting if us having to add if statements in the code to see if the checkbox exists and was causing issues in some tests too. Removing this fixes the issues.

Copy link
Collaborator

Choose a reason for hiding this comment

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

How are you feeling about rxHostPressedListener? That was a super early implementation and not sure if it's worth the upkeep!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I agree, personally I think it's easier and more obvious just to add a two hostlisteners. Saves jumping between files and it's not immediately obvious what this functions purpose is. I don't really see the benefit in it myself.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It was supposed to be advanced into something like usePress from React Aria, which is great for mobile apps. But I never got around to that. Happy to deprecate/remove before v1

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense. If that is ever something you want to bring in, I ported all those interactions from react aria to angular for angular primitives, so they could easily be carried over to Spartan.

Copy link
Collaborator Author

@ashley-hunter ashley-hunter Nov 12, 2024

Choose a reason for hiding this comment

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

I have now removed the rxHostListeners from all components. Wasn't used in many places.

@ashley-hunter ashley-hunter marked this pull request as ready for review November 11, 2024 22:43
@goetzrobin goetzrobin merged commit b959565 into main Nov 12, 2024
10 of 11 checks passed
@goetzrobin goetzrobin deleted the switch-signals branch November 12, 2024 15:23
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.

refactor(switch): migration to signals
2 participants