From fd8a5900362c3af4964ac1d638c0b9e8b4cc3a48 Mon Sep 17 00:00:00 2001 From: Attila Orosz Date: Wed, 1 Feb 2023 18:08:02 +0100 Subject: [PATCH] docs: document scopedContainerDisposer --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a603487..2e9d82fd 100644 --- a/README.md +++ b/README.md @@ -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(); @@ -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'], });