Home / Function/ subscribeToPathname() — supabase Function Reference

subscribeToPathname() — supabase Function Reference

Architecture documentation for the subscribeToPathname() function in Reference.navigation.client.tsx from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  93211543_8a76_43aa_25fb_52828b300d3c["subscribeToPathname()"]
  bc4f454e_b3dc_9292_f2bf_ee8a602b6add["notifyPathnameListeners()"]
  93211543_8a76_43aa_25fb_52828b300d3c -->|calls| bc4f454e_b3dc_9292_f2bf_ee8a602b6add
  style 93211543_8a76_43aa_25fb_52828b300d3c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/features/docs/Reference.navigation.client.tsx lines 38–70

function subscribeToPathname(callback: () => void) {
  pathnameListeners.add(callback)

  if (patchCount === 0) {
    window.addEventListener('popstate', notifyPathnameListeners)

    originalPushState = history.pushState.bind(history)
    history.pushState = (...args) => {
      originalPushState!(...args)
      notifyPathnameListeners()
    }

    originalReplaceState = history.replaceState.bind(history)
    history.replaceState = (...args) => {
      originalReplaceState!(...args)
      notifyPathnameListeners()
    }
  }
  patchCount++

  return () => {
    pathnameListeners.delete(callback)
    patchCount--

    if (patchCount === 0) {
      window.removeEventListener('popstate', notifyPathnameListeners)
      history.pushState = originalPushState!
      history.replaceState = originalReplaceState!
      originalPushState = null
      originalReplaceState = null
    }
  }
}

Subdomains

Frequently Asked Questions

What does subscribeToPathname() do?
subscribeToPathname() is a function in the supabase codebase.
What does subscribeToPathname() call?
subscribeToPathname() calls 1 function(s): notifyPathnameListeners.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free