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

feat(plugin-history-sync): add history queue context #417

Merged
merged 13 commits into from
Oct 31, 2023

Conversation

orionmiz
Copy link
Member

@orionmiz orionmiz commented Oct 20, 2023

URL navigations not managed in history sync plugin can be ignored when those are executed right after the stackflow actions.

This PR provides a solution about the issue by exposing enqueue function as a hook so that navigations could be inserted into the queue together.

@vercel
Copy link

vercel bot commented Oct 20, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
stackflow-docs ✅ Ready (Inspect) Visit Preview Oct 31, 2023 9:54am

Copy link
Member

@tonyfromundefined tonyfromundefined left a comment

Choose a reason for hiding this comment

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

enqueue() is a raw API-like name that reveals the perception that the inside is a queue, so I wonder if it would be right to expose it to the outside.

I understand that the queue is managed globally, but wouldn't it be better to remove the react dependency and use an API like requestHistoryTick()? (I think there is a better name than this one... If so, please suggest one.)

import { requestHistoryTick } from "@stackflow/plugin-history-sync";

requestHistoryTick(() => {
  console.log("Manipulate history safely here!")
});

Reference interfaces:

@orionmiz
Copy link
Member Author

enqueue function cannot be exported as a module since history object is not determined at the module load.
But renaming the function enqueue into requestHistoryTick seems like a great idea 👍

Copy link
Member

@tonyfromundefined tonyfromundefined left a comment

Choose a reason for hiding this comment

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

LGTM!

@orionmiz orionmiz merged commit f0af73c into main Oct 31, 2023
4 checks passed
@orionmiz orionmiz deleted the history-queue-context branch October 31, 2023 10:33
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