On this page
Observe registration and runtime lifecycles๏
Prerequisite: configuration. Hooks attach observation to a
book or registration so call sites can keep using ordinary meld and lifecycle verbs.
Pick the boundary you need๏
Boundary |
Registration surface |
Saved demonstration |
|---|---|---|
Spell creation |
|
Record construction events |
Meld |
|
Observe pre/post resolution |
Conduit |
The same book-keyed hook registration |
Observe creation and cleanup |
Links and contracts |
The same book-keyed hook registration |
Observe linking, pull, and sever |
The book ID matters when a configuration serves several books. Register the callbacks before the lifecycle operation you intend to observe. The runnable examples collect events in memory so you can inspect what actually fired.
Keep the result separate from the observation๏
A hook records a moment in a lifecycle. The meld still supplies the resolved object. Use the meld-hook lesson's repeated resolutions and event counts as a small working pattern; use the conduit lesson when cleanup observation matters.
For the dynamic arc, read linking before the link-hook lesson. The latter observes the same owner/borrower operations; it adds no alternative sharing procedure.
The workflow in code๏
These are the core steps from the saved example. Use its complete linked script for all class definitions and setup.
1def main() -> None:
2 events = []
3
4 book = md.Spellbook()
5 config = book.get_configuration()
6 config.add_hook(book.id, "on_meld_pre_resolve",
7 lambda *a, **k: events.append("pre"))
8 config.add_hook(book.id, "on_meld_post_resolve",
9 lambda *a, **k: events.append("post"))
10
11 book.bind(spell=Watched, existence="many")
12 conduit = book.conjure()
13
14 conduit.meld(spell=Watched)
15 conduit.meld(spell=Watched)
16 print("meld pipeline observed:", events)
17 assert events.count("pre") >= 2 and events.count("post") >= 2
18 print("every meld fired pre and post - the pipeline is watchable")
Runnable examples๏
Config meld hooks โ Intermediate 32
Registration hooks โ Intermediate 03
Config conduit lifecycle hooks โ Intermediate 33
Config link and contract hooks โ Intermediate 34
All intermediate examples ยท Level contents ยท Full contents