Skip to content

[WIP] Swift style KVO pattern #2344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

[WIP] Swift style KVO pattern #2344

wants to merge 1 commit into from

Conversation

liamappelbe
Copy link
Contributor

@liamappelbe liamappelbe commented Jun 5, 2025

Usage:

  1. Implement the Observer protocol
  2. Call object.addObserver(observer, ...)
  3. addObserver returns an Observation, which must be held for as long as you want to keep receiving updates
  4. The Observation object holds strong refs to the Observer and the observed object, keeping them alive
  5. Call observation.remove(), or allow it to go out of scope and be GC'd, and the observations will stop

TODO: Observation should probably drop its references to the Observer and observed object when .remove() is called.

#1508

Copy link

github-actions bot commented Jun 5, 2025

PR Health

Breaking changes ⚠️
Package Change Current Version New Version Needed Version Looking good?
objective_c Breaking 8.0.0 8.1.0-wip 9.0.0
Got "8.1.0-wip" expected >= "9.0.0" (breaking changes)
⚠️

This check can be disabled by tagging the PR with skip-breaking-check.

Changelog Entry
Package Changed Files
package:objective_c pkgs/objective_c/lib/objective_c.dart
pkgs/objective_c/lib/src/objective_c_bindings_exported.dart
pkgs/objective_c/lib/src/objective_c_bindings_generated.dart
pkgs/objective_c/lib/src/observer.dart

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check.

API leaks ⚠️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbols
objective_c _FinalizablePointer
_Version

This check can be disabled by tagging the PR with skip-leaking-check.

License Headers ✔️
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files
no missing headers

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/jni/lib/src/third_party/generated_bindings.dart
pkgs/native_doc_dartifier/example/native_doc_dartifier_example.dart
pkgs/native_doc_dartifier/lib/native_doc_dartifier.dart
pkgs/native_doc_dartifier/lib/src/native_doc_dartifier_base.dart
pkgs/native_doc_dartifier/test/native_doc_dartifier_test.dart
pkgs/objective_c/lib/src/ns_input_stream.dart

@coveralls
Copy link

Coverage Status

coverage: 86.987%. first build
when pulling 0aee008 on objc_kvo_swift
into 7f5bfa6 on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants