Skip to content

refactor: Update names & types for nav handler to make it more clear #99

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

Merged
merged 2 commits into from
Jun 25, 2025

Conversation

rschristian
Copy link
Member

UPDATE has become a bit unclear over the years, largely due to the naming of the reducer action (url). This can be an event, a string, an object containing url & replace properties for programmatic nav, etc. Needed a bit of a rename.

Largely copies work from #75.

Comment on lines -37 to -38
} else if (typeof url === 'string') {
push = true;
Copy link
Member Author

Choose a reason for hiding this comment

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

This branch has been dead since #8.

It used to support the route() function for programmatic nav, but with the addition of the replace parameter, that uses the form of handleNav({ url, replace }) -- it's no longer a singular string param.


/**
* @param {string} state
* @param {MouseEvent | PopStateEvent | { url: string, replace?: boolean }} action
Copy link
Member Author

Choose a reason for hiding this comment

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

By no means does the following code pass TS's inspection, but it's at least easy to reason about. We can always sprinke in instanceof or prop in action checks later if really needed.

@rschristian rschristian marked this pull request as ready for review June 25, 2025 06:03
@rschristian rschristian merged commit 82cdde4 into main Jun 25, 2025
1 check passed
@rschristian rschristian deleted the refactor/handle-nav branch June 25, 2025 06:03
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.

1 participant