Skip to main content

Function: withCleanupScope()

withCleanupScope(cleanupFunction): () => void

Operations that are releasing memory from JS should be executed after cleanup functions that are still operating on the resource. For example in a cleanup you might remove an asset from the scene, but you also want to release the memory of the asset. The memory release() function call should be wrapped with withCleanupScope.

Parameters​

• cleanupFunction: Function

Returns​

Function

Returns​

void

Note​

You probably don't need to call this yourself!

Example​

useEffect(() => {
const asset = // ... acquire some resources

return withCleanupScope(() => {
asset.release()
})
})

Defined in​

src/utilities/withCleanupScope.ts:23