-{"hierarchy":{"paths":[["doc:\/\/FactoryKit\/documentation\/FactoryKit"]]},"schemaVersion":{"patch":0,"major":0,"minor":3},"identifier":{"interfaceLanguage":"swift","url":"doc:\/\/FactoryKit\/documentation\/FactoryKit\/AutoRegistering"},"sections":[],"variants":[{"paths":["\/documentation\/factorykit\/autoregistering"],"traits":[{"interfaceLanguage":"swift"}]}],"primaryContentSections":[{"declarations":[{"platforms":["macOS"],"languages":["swift"],"tokens":[{"text":"protocol","kind":"keyword"},{"text":" ","kind":"text"},{"text":"AutoRegistering","kind":"identifier"}]}],"kind":"declarations"},{"kind":"content","content":[{"text":"Overview","anchor":"overview","type":"heading","level":2},{"inlineContent":[{"type":"text","text":"Add this protocol to a container to support first-time registration of needed dependencies prior to first resolution"},{"type":"text","text":" "},{"type":"text","text":"of a dependency on that container."}],"type":"paragraph"},{"syntax":"swift","type":"codeListing","code":["extension Container: @retroactive AutoRegistering {"," func autoRegister() {"," someService.register {"," CrossModuleService()"," }"," }","}"]},{"inlineContent":[{"text":"The ","type":"text"},{"type":"codeVoice","code":"autoRegister"},{"text":" function is called on each instantiated container prior to","type":"text"},{"text":" ","type":"text"},{"text":"the first resolution of a Factory on that container.","type":"text"}],"type":"paragraph"},{"style":"warning","type":"aside","name":"Warning","content":[{"type":"paragraph","inlineContent":[{"text":"Calling ","type":"text"},{"code":"container.manager.reset(options: .all)","type":"codeVoice"},{"text":" restores the container to it’s initial state","type":"text"},{"text":" ","type":"text"},{"text":"and autoRegister will be called again if it exists.","type":"text"}]}]},{"inlineContent":[{"text":"The ","type":"text"},{"code":"@retroactive","type":"codeVoice"},{"text":" attribute is needed as of Swift 6 to silence a conformance warning.","type":"text"}],"type":"paragraph"}]}],"metadata":{"title":"AutoRegistering","roleHeading":"Protocol","role":"symbol","navigatorTitle":[{"text":"AutoRegistering","kind":"identifier"}],"modules":[{"name":"FactoryKit"}],"fragments":[{"kind":"keyword","text":"protocol"},{"kind":"text","text":" "},{"kind":"identifier","text":"AutoRegistering"}],"externalID":"s:10FactoryKit15AutoRegisteringP","symbolKind":"protocol"},"topicSections":[{"anchor":"Instance-Methods","title":"Instance Methods","identifiers":["doc:\/\/FactoryKit\/documentation\/FactoryKit\/AutoRegistering\/autoRegister()"],"generated":true}],"kind":"symbol","abstract":[{"text":"Adds an registration “hook” to a ","type":"text"},{"type":"codeVoice","code":"Container"},{"text":".","type":"text"}],"references":{"doc://FactoryKit/documentation/FactoryKit/AutoRegistering/autoRegister()":{"title":"autoRegister()","identifier":"doc:\/\/FactoryKit\/documentation\/FactoryKit\/AutoRegistering\/autoRegister()","url":"\/documentation\/factorykit\/autoregistering\/autoregister()","role":"symbol","fragments":[{"text":"func","kind":"keyword"},{"text":" ","kind":"text"},{"text":"autoRegister","kind":"identifier"},{"text":"()","kind":"text"}],"kind":"symbol","type":"topic","required":true,"abstract":[{"text":"User provided function that supports first-time registration of needed dependencies prior to first resolution","type":"text"},{"text":" ","type":"text"},{"text":"of a dependency on that container.","type":"text"}]},"doc://FactoryKit/documentation/FactoryKit/AutoRegistering":{"abstract":[{"type":"text","text":"Adds an registration “hook” to a "},{"type":"codeVoice","code":"Container"},{"type":"text","text":"."}],"type":"topic","role":"symbol","kind":"symbol","navigatorTitle":[{"text":"AutoRegistering","kind":"identifier"}],"identifier":"doc:\/\/FactoryKit\/documentation\/FactoryKit\/AutoRegistering","fragments":[{"text":"protocol","kind":"keyword"},{"text":" ","kind":"text"},{"text":"AutoRegistering","kind":"identifier"}],"title":"AutoRegistering","url":"\/documentation\/factorykit\/autoregistering"},"doc://FactoryKit/documentation/FactoryKit":{"abstract":[{"text":"A modern approach to Container-Based Dependency Injection for Swift and SwiftUI.","type":"text"}],"url":"\/documentation\/factorykit","type":"topic","title":"FactoryKit","identifier":"doc:\/\/FactoryKit\/documentation\/FactoryKit","kind":"symbol","role":"collection"}}}
0 commit comments