Skip to content

Instantly share code, notes, and snippets.

@lisonge
Last active November 12, 2025 04:21
Show Gist options
  • Select an option

  • Save lisonge/f7221a04ce533260fd5480e4b7e5fb3a to your computer and use it in GitHub Desktop.

Select an option

Save lisonge/f7221a04ce533260fd5480e4b7e5fb3a to your computer and use it in GitHub Desktop.
export const createInheritedComposable = <F extends (...args: any[]) => any>(fn: F): F => {
const key = Symbol('inherited-composable-' + Date.now())
return ((...args: any[]) => {
let r: any = inject(key, key)
if (r === key) {
r = fn(...args)
provide(key, r)
}
return r
}) as F
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment