PageSourceSearch

https://inversify.io/assets/js/3bcf9585.d36ca1eb.js

js inversify.io collected 2026-10-02 08:15:29 UTC 4,105 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_inversifyjs_inversify_docs_site=self.webpackChunk_inversifyjs_inversify_docs_site||[]).push([["3261"],{32304(e,n,i){i.r(n),i.d(n,{metadata:()=>r,default:()=>h,frontMatter:()=>a,contentTitle:()=>d,toc:()=>l,assets:()=>c});var r=JSON.parse('{"id":"ecosystem/binding-decorators","title":"Binding Decorators","description":"The @inversifyjs/binding-decorators package provides a set of handy decorators that streamline configuring bindings in your InversifyJS Container. Instead of manually calling bind for each service, you can use decorators like @provide() to declare and organize dependencies close to their implementation.","source":"@site/docs/ecosystem/binding-decorators.mdx","sourceDirName":"ecosystem","slug":"/ecosystem/binding-decorators","permalink":"/docs/next/ecosystem/binding-decorators","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":1,"frontMatter":{"sidebar_position":1,"title":"Binding Decorators"},"sidebar":"tutorialSidebar","previous":{"title":"Migrating from v7","permalink":"/docs/next/guides/migrating-from-v7"},"next":{"title":"Framework","permalink":"/docs/next/ecosystem/framework"}}'),s=i(89292),o=i(19736),t=i(85817);let a={sidebar_position:1,title:"Binding Decorators"},d="Inversify binding decorators",c={},l=[{value:"When to use it",id:"when-to-use-it",level:2},{value:"Key features",id:"key-features",level:2},{value:"Documentation",id:"documentation",level:2}];function u(e){let n={code:"code",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",ul:"ul",...(0,o.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"inversify-binding-decorators",children:"Inversify binding decorators"})}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"@inversifyjs/binding-decorators"})," package provides a set of handy decorators that streamline configuring bindings in your InversifyJS Container. Instead of manually calling ",(0,s.jsx)(n.code,{children:"bind"})," for each service, you can use decorators like ",(0,s.jsx)(n.code,{children:"@provide()"})," to declare and organize dependencies close to their implementation."]}),"\n",(0,s.jsx)(n.h2,{id:"when-to-use-it",children:"When to use it"}),"\n",(0,s.jsx)(n.p,{children:"Use binding decorators when you prefer annotation-driven configuration that:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"Reduces container setup boilerplate"}),"\n",(0,s.jsx)(n.li,{children:"Keeps bindings co-located with class definitions"}),"\n",(0,s.jsx)(n.li,{children:"Improves discoverability of services in larger codebases"}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"If you need fully programmatic or dynamic binding logic, traditional module / container binding code may still be more appropriate."}),"\n",(0,s.jsx)(n.h2,{id:"key-features",children:"Key features"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.code,{children:"@provide()"})," decorator to auto-register classes"]}),"\n",(0,s.jsx)(n.li,{children:"Support for named and tagged bindings"}),"\n",(0,s.jsx)(n.li,{children:"Layered on top of the core container so it stays optional"}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"documentation",children:"Documentation"}),"\n",(0,s.jsx)(n.p,{children:"You can find the full documentation, examples, and usage guidance here:"}),"\n",(0,s.jsx)(t.A,{href:"https://inversify.io/binding-decorators/",target:"_blank",children:(0,s.jsx)("span",{children:"View Full Documentation"})})]})}function h(e={}){let{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(u,{...e})}):u(e)}},85817(e,n,i){i.d(n,{A:()=>o});var r=i(89292),s=i(52769);i(83888);function o({href:e,children:n,target:i}){return(0,r.jsx)("div",{className:"buttonContainer_jyGP",children:(0,r.jsxs)(s.A,{to:e,target:i,rel:"noopener noreferrer",className:"documentationButton_Sex6",children:[(0,r.jsx)("span",{className:"buttonText_NSOW",children:n}),(0,r.jsx)("span",{className:"buttonIcon_fV4z",children:"\u{1F4D6}"}),(0,r.jsx)("div",{className:"shimmer_GGMR"})]})})}}}]);

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.