1"use strict";(self.webpackChunk_inversifyjs_inversify_docs_site=self.webpackChunk_inversifyjs_inversify_docs_site||[]).push([["3121"],{13011(n,e,t){t.r(e),t.d(e,{assets:()=>s,contentTitle:()=>l,default:()=>g,frontMatter:()=>r,metadata:()=>i,toc:()=>c});var i=t(16262),o=t(89292),a=t(19736);t(94152),t(21422),t(48314);let r={slug:"announcing-inversify-7-0-0-alpha-4-prerelease",title:"Announcing 7.0.0-alpha.4",authors:["notaphplover"],tags:["releases"]},l,s={authorsImageUrls:[void 0]},c=[];function p(n){let e={p:"p",...(0,a.R)(),...n.components};return(0,o.jsx)(e.p,{children:"In this version, we are announcing a new type of binding!"})}function g(n={}){let{wrapper:e}={...(0,a.R)(),...n.components};return e?(0,o.jsx)(e,{...n,children:(0,o.jsx)(p,{...n})}):p(n)}},94152(n){n.exports="container.bind<Engine>('Engine').to(PetrolEngine).whenNamed('petrol');\ncontainer.bind<Engine>('Engine').to(DieselEngine).whenNamed('diesel');\n\ncontainer\n .bind<Factory<(displacement: number) => Engine, [string]>>('Factory<Engine>')\n .toFactory((context: ResolutionContext) => {\n return (named: string) => (displacement: number) => {\n const engine: Engine = context.get<Engine>('Engine', {\n name: named,\n });\n engine.displacement = displacement;\n return engine;\n };\n });\n\n@injectable()\nclass DieselCarFactory implements CarFactory {\n readonly #dieselFactory: (displacement: number) => Engine;\n\n constructor(\n @inject('Factory<Engine>')\n factory: (category: string) => (displacement: number) => Engine, // Injecting an engine factory\n ) {\n // Creating a diesel engine factory\n this.#dieselFactory = factory('diesel');\n }\n\n public createEngine(displacement: number): Engine {\n // Creating a concrete diesel engine\n return this.#dieselFactory(displacement);\n }\n}"},21422(n){n.exports="class Katana {\n public material!: string;\n public damage!: number;\n}\n\nconst dbConnectionSymbol: symbol = Symbol.for('DbConnection');\nconst katanaDbCollectionSymbol: symbol = Symbol.for('KatanaRepository');\n\nconst container: Container = new Container();\n\n@injectable()\nclass KatanaRepository {\n readonly #dbCollection: AwesomeDbDriverCollection<Katana>;\n\n constructor(\n @inject(katanaDbCollectionSymbol)\n dbCollection: AwesomeDbDriverCollection<Katana>,\n ) {\n this.#dbCollection = dbCollection;\n }\n\n public async find(query: unknown): Promise<Katana[]> {\n return this.#dbCollection.find(query);\n }\n}\n\ncontainer.bind(MyAwesomeEnvService).toSelf();\ncontainer\n .bind(dbConnectionSymbol)\n .toResolvedValue(\n async (\n envService: MyAwesomeEnvService,\n ): Promise<AwesomeDbDriverConnection> => {\n const databaseUrl: string = envService.getEnvironment().dbUrl;\n\n return AwesomeDbDriverImplementation.connect(databaseUrl);\n },\n [MyAwesomeEnvService],\n )\n .inSingletonScope();\n\ncontainer\n .bind(katanaDbCollectionSymbol)\n .toResolvedValue(\n (\n connection: AwesomeDbDriverConnection,\n ): AwesomeDbDriverCollection<Katana> => {\n return connection.getCollection(Katana);\n },\n [dbConnectionSymbol],\n )\n .inSingletonScope();\n\ncontainer.bind(KatanaRepository).toSelf();"},16262(n){n.exports=JSON.parse('{"permalink":"/blog/announcing-inversify-7-0-0-alpha-4-prerelease","source":"@site/blog/2025-02-02-announcing-inversify-7-0-0-alpha-4-prerelease/index.mdx","title":"Announcing 7.0.0-alpha.4","description":"In this version, we are announcing a new type of binding!","date":"2025-02-02T00:00:00.000Z","tags":[{"inline":false,"label":"Releases","permalink":"/blog/tags/releases","description":"InversifyJS releases related posts"}],"readingTime":1.4,"hasTruncateMarker":true,"authors":[{"name":"Roberto Pintos L\xf3pez","title":"InversifyJS maintainer","url":"https://github.com/notaphplover","page":{"permalink":"/blog/authors/notaphplover"},"socials":{"github":"https://github.com/notaphplover"},"imageURL":"https://github.com/notaphplover.png","key":"notaphplover"}],"frontMatter":{"slug":"announcing-inversify-7-0-0-alpha-4-prerelease","title":"Announcing 7.0.0-alpha.4","authors":["notaphplover"],"tags":["releases"]},"unlisted":false,"prevItem":{"title":"Announcing 7.0.0-alpha.5","permalink":"/blog/announcing-inversify-7-0-0-alpha-5-prerelease"},"nextItem":{"title":"Announcing 7.0.0-alpha.2","permalink":"/blog/announcing-inversify-7-0-0-alpha-2-prerelease"}}')}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.