scheduleFlushToURL is a function that you would find in update-queue.ts file in nuqs package. To understand what this function does, we can review the comment, defined just above this function starting from line number 73.
Here’s the functon’s comment:
/** * Eventually flush the update queue to the URL query string. * * This takes care of throttling to avoid hitting browsers limits * on calls to the history pushState/replaceState APIs, and defers * the call so that individual query state updates can be batched * when running in the same event loop tick. * * @returns a Promise to the URLSearchParams that have been applied. */export function scheduleFlushToURL({ getSearchParamsSnapshot = getSearchParamsSnapshotFromLocation, updateUrl, rateLimitFactor = 1}: Pick< AdapterInterface, 'updateUrl' | 'getSearchParamsSnapshot' | 'rateLimitFactor'>) {
At line number 22, you will find a variable named flushPromiceCache and Its return type is Promise<URLSearchParams> and it is initialized to null.At line number 91, you will find this if Statement:
if (flushPromiseCache === null) {
A new promise is assigned to the variable flushPromiseCache. It does some computation and there is also debug used.
There are two functions that are defined inside this promise the first one is flushNow.
Hey, my name is Ramu Narasinga. I study large open-source projects and create content about their codebase architecture and best practices, sharing it through articles, videos.
Configure features such as Changesets, Supabase auth in your Next.js project usingThink Throo CLI.