MCPcopy Create free account
hub / github.com/thetarnav/solid-devtools / onOwnerCleanup

Function onOwnerCleanup

packages/debugger/src/main/utils.ts:230–252  ·  view source on GitHub ↗
(
    owner: Solid.Owner,
    fn: VoidFunction,
    prepend = false,
    symbol?: symbol,
)

Source from the content-addressed store, hash-verified

228 * @returns a function to remove the cleanup callback
229 */
230export function onOwnerCleanup(
231 owner: Solid.Owner,
232 fn: VoidFunction,
233 prepend = false,
234 symbol?: symbol,
235): VoidFunction {
236 if (owner.cleanups === null) owner.cleanups = [fn]
237 else {
238 if (symbol) {
239 if (owner.cleanups.some(c => (c as any)[symbol])) {
240 return () =>
241 owner.cleanups?.splice(
242 owner.cleanups.findIndex(c => (c as any)[symbol]),
243 1,
244 )
245 }
246 ;(fn as any)[symbol] = true
247 }
248 if (prepend) owner.cleanups.unshift(fn)
249 else owner.cleanups.push(fn)
250 }
251 return () => owner.cleanups?.splice(owner.cleanups.indexOf(fn), 1)
252}
253
254/**
255 * Attach onCleanup callback to the parent of a reactive owner if it has one.

Callers 5

attachDebuggerFunction · 0.90
onParentCleanupFunction · 0.90
registerComponentFunction · 0.90
onParentCleanupFunction · 0.85
onOwnerDisposeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…