On this page

Spellframes and categories๏ƒ

Beginner. The organizing half of every address.

A spellframe is the category half of the Address Law. It can be a plain string when you just want grouping, or a Protocol when you want a shape:

# strings โ€” organize by role
book.bind(spell=UsersRepo, existence="unique",
          spellframe="storage", binding_name="users")
book.bind(spell=UsersApi,  existence="unique",
          spellframe="web",     binding_name="users")

repo = conduit.meld(spellframe="storage", binding_name="users")
api  = conduit.meld(spellframe="web",     binding_name="users")

Same binding_name, two categories, two distinct addresses โ€” names never collide across spellframes. And because a Protocol works as a spellframe, one category can mean "everything that satisfies this shape," which is exactly what collection DI resolves:

book.bind(spell=EmailHandler, existence="unique",
          spellframe=Handler, binding_name="email")

Runnable examples๏ƒ

All beginner examples ยท Level contents ยท Full contents

Canonical page source