detach method

MemoryPointer<RFunction<R>> detach([
  1. bool keepAlive = false
])

Removes this callback from registry, optionally disposes it, and returns its function pointer.

If keepAlive is true, the callback is neither removed from registry nor disposed, only the pointer is returned. Useful when temporarily detaching without releasing resources.

Implementation

MemoryPointer<RFunction<R>> detach([bool keepAlive = false]) {
  final ptr = nativeFunction;
  if (keepAlive) return ptr;
  registry.remove(ptr.address);
  dispose();
  return nativeFunction;
}