Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,12 @@ You will get a new instance for each event in the controller.

The `scopedContainerGetter` function receives a parameter which contains the socket, socket.io instance, event type, event name, namespace parameters and the message arguments if they are applicable.

The `scopedContainerDisposer` function receives the container instance you created with `scopedContainerGetter` after the socket action is finished. Use this function to dispose the container if needed.

```typescript
import 'reflect-metadata';
import { SocketControllers, ScopedContainerGetterParams } from 'socket-controllers';
import { Container, Token } from "typedi";
import { Container, ContainerInstance, Token } from "typedi";

const myDiToken = new Token();

Expand All @@ -486,6 +488,9 @@ const server = new SocketControllers({
container.set(myDiToken, 'MY_VALUE');
return container;
},
scopedContainerDisposer: (container: ContainerInstance) => {
container.dispose();
},
controllers: [__dirname + '/controllers/*.js'],
middlewares: [__dirname + '/middlewares/*.js'],
});
Expand Down