-
Notifications
You must be signed in to change notification settings - Fork 607
v1: Auto-registering of services #5600
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
Conversation
Introduces the ServiceHost control in both Dart and Python SDKs, enabling hosting and management of services for child controls. Updates documentation, mkdocs navigation, and core extension registration to support ServiceHost.
Implemented the __call__ method in the Ref class to allow instances to be called directly, returning the current referenced object. This enhances usability and provides a more intuitive API.
Corrected image and anchor links in documentation for tabs and Android publishing. Updated type annotations and return types in cache.py for clarity. Fixed indentation in docstrings for alert_dialog.py and chip.py.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've reviewed this pull request using the Sourcery rules engine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a ServiceHost control to both the Dart and Python SDKs, enabling lifecycle management of hosted services. It also includes several API improvements and documentation fixes.
- ServiceHost control implementation for managing service lifecycles and exposing them to child controls
- Enhanced Ref control with callable interface for direct value access
- Improved type annotations and proper service disposal in ServiceRegistry
Reviewed Changes
Copilot reviewed 11 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| sdk/python/packages/flet/src/flet/controls/ref.py | Added __call__ method to Ref for direct value retrieval |
| sdk/python/packages/flet/src/flet/controls/core/service_host.py | New ServiceHost control implementation in Python |
| sdk/python/packages/flet/src/flet/controls/cache.py | Improved typing for cache decorator return signature |
| sdk/python/packages/flet/src/flet/init.py | Added ServiceHost to Python package exports |
| packages/flet/lib/src/services/service_registry.dart | Added dispose method for proper service cleanup |
| packages/flet/lib/src/controls/service_host.dart | New ServiceHost control implementation in Dart |
| packages/flet/lib/src/flet_core_extension.dart | Registered ServiceHost control and reorganized switch cases |
| sdk/python/packages/flet/mkdocs.yml | Added ServiceHost documentation to navigation |
| sdk/python/packages/flet/docs/controls/servicehost.md | Created ServiceHost documentation page |
| sdk/python/packages/flet/docs/publish/android.md | Fixed broken reference link |
| sdk/python/packages/flet/docs/controls/tabs/index.md | Fixed broken image path |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
sdk/python/packages/flet/src/flet/controls/core/service_host.py
Outdated
Show resolved
Hide resolved
Corrected grammar in the ServiceHost class docstring from 'make' to 'makes' for clarity.
Deploying flet-docs with
|
| Latest commit: |
937f0e9
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://270b4eda.flet-docs.pages.dev |
| Branch Preview URL: | https://v1-servicehost.flet-docs.pages.dev |
Replaces 'services' with '_services' in ServiceRegistry and updates related references for encapsulation. Introduces thread safety and cleanup for unreferenced services. Refactors auto-update logic to use a unified 'after_event' method, simplifying event handling and service lifecycle management. Improves error handling in context and updates property access patterns for services in Page.
Updated the Dart PageControl to initialize ServiceRegistry with the main control instead of its child, simplifying service management. In Python, replaced the _page_services ServiceRegistry with a direct _services list, updating references and related tests for consistency.
Deleted the ServiceHost control implementation, its documentation, and references from mkdocs navigation and __init__.py. This change removes ServiceHost from the public API and documentation, likely due to deprecation or refactoring.
Deleted the ServiceHostControl widget and its import and usage from flet_core_extension.dart. This refactor removes support for the ServiceHost control, likely due to deprecation or architectural changes.
ServiceHost controlDeleted the unused 'bind' method from the Page class to clean up the codebase and improve maintainability.
Refactored the ServiceRegistry method name from cleanup to unregister_services for clarity. Updated references in session.py to use the new method name.
Deleted the unused ModelT TypeVar declaration to clean up the code in page.py.
Close #5506
Services can now be used right away, without adding them to
page.services, for example: