implementAsBlocking static method

Observer implementAsBlocking({
  1. required void observeValueForKeyPath_ofObject_change_context_(
    1. NSString,
    2. ObjCObject,
    3. NSDictionary,
    4. Pointer<Void>,
    ),
  2. bool $keepIsolateAlive = true,
})

Builds an object that implements the Observer protocol. To implement multiple protocols, use addToBuilder or objc.ObjCProtocolBuilder directly. All methods that can be implemented as blocking listeners will be.

If $keepIsolateAlive is true, this protocol will keep this isolate alive until it is garbage collected by both Dart and ObjC.

Implementation

static Observer implementAsBlocking({
  required void Function(
    NSString,
    objc.ObjCObject,
    NSDictionary,
    ffi.Pointer<ffi.Void>,
  )
  observeValueForKeyPath_ofObject_change_context_,
  bool $keepIsolateAlive = true,
}) {
  final builder = objc.ObjCProtocolBuilder(debugName: 'Observer');
  Observer$Builder.observeValueForKeyPath_ofObject_change_context_
      .implementAsBlocking(
        builder,
        observeValueForKeyPath_ofObject_change_context_,
      );
  builder.addProtocol($protocol);
  return Observer.as(builder.build(keepIsolateAlive: $keepIsolateAlive));
}