Skip to content

[IMP] owl-core: add clear method on Resource and Registry - #2006

Merged
mcm-odoo merged 1 commit into
masterfrom
master-registry-clear-ged
Jul 29, 2026
Merged

[IMP] owl-core: add clear method on Resource and Registry#2006
mcm-odoo merged 1 commit into
masterfrom
master-registry-clear-ged

Conversation

@ged-odoo

Copy link
Copy Markdown
Contributor

Resource and Registry could only be emptied one entry at a time. This PR adds a clear method on both.

resource.add("a").add("b").clear();
resource.items(); // []

registry.add("form", View).clear();
registry.has("form"); // false

Each container is backed by a single signal, so clear replaces the underlying value: subscribers are notified once and items()/entries() recompute. Entries added through use() are removed as well — their scope cleanup is either guarded or a no-op filter, so nothing reappears when the component or plugin is destroyed.

Resource.clear is chainable and Registry.clear returns void, mirroring delete on each class.

Also documented in the Resource / Registry reference pages (new sections + API summary rows).

`Resource` and `Registry` could only be emptied one entry at a time. Add a
`clear` method on both, which removes everything at once.

Each container is backed by a single signal, so `clear` replaces the underlying
value: subscribers are notified once, and `items()`/`entries()` recompute.
Entries added through `use()` are removed as well, and their scope cleanup
becomes a no-op, so nothing reappears when the component or plugin is
destroyed.

`clear` returns `void` on both classes: there is nothing left to operate on, so
chaining would be pointless. `Registry.delete` however was the only removal
method that was not chainable, unlike `Resource.delete` and every other
`Registry` method, so it now returns the registry as well.
@ged-odoo
ged-odoo force-pushed the master-registry-clear-ged branch from 7def0f4 to ff03afc Compare July 29, 2026 12:30
@mcm-odoo
mcm-odoo merged commit 9bb3337 into master Jul 29, 2026
2 checks passed
@mcm-odoo
mcm-odoo deleted the master-registry-clear-ged branch July 29, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants