(
owner: Solid.Owner,
fn: VoidFunction,
prepend = false,
symbol?: symbol,
)
| 228 | * @returns a function to remove the cleanup callback |
| 229 | */ |
| 230 | export 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. |
no outgoing calls
no test coverage detected
searching dependent graphs…