Skip to content

Commit e1fb0cb

Browse files
committed
remove bindings
1 parent 6473298 commit e1fb0cb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

service-container.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,20 @@ this.app()
116116
Like bindings, aliases support class constructors as well. You may create an alias pointing from a string namespace to a class namespace (`app.alias('server', Server)`).
117117

118118

119+
### Remove Bindings
120+
*added in version `3.15`*
121+
122+
Sometimes you need to remove a bound singleton binding instance and let the container create a new one. Use the `forgetInstance` method to remove a singleton binding from the container’s cache and let it freshly resolve a new instance:
123+
124+
```ts
125+
import { Application } from '@supercharge/contracts'
126+
import { DocsRenderer } from './services/docs-renderer'
127+
128+
this.app().forgetInstance('binding.name')
129+
this.app().forgetInstance(BoundClass)
130+
```
131+
132+
119133
## Resolving
120134
You can resolve class instances from the container using the `make` method. The `make` method accepts a string or class you wish to resolve:
121135

0 commit comments

Comments
 (0)