On this page
Constructor dependency injection๏
Beginner โ Intermediate. Annotations, explicit targets, collections.
Annotate a constructor parameter. Melder builds the graph.
class ReportService:
def __init__(self, database: Database) -> None: # โ injected
self.database = database
book.bind(spell=Database, existence="unique")
book.bind(spell=ReportService, existence="unique")
conduit = book.conjure()
report = conduit.meld("ReportService")
Runnable examples๏
Constructor di by annotation โ Intermediate 15
Typed melding โ Beginner 16