# Namespace Decorator

Module
import { Namespace } from "@tsed/socketio"
Source/packages/socketio/src/decorators/nsp.ts

# Overview

type Namespace = NamespaceType;
function Namespace(target: any, propertyKey?: string, index?: number): any;

# Description

Inject the SocketIO.Namespace instance in the decorated parameter.

# Example

import {Namespace, SocketService, Input} from "@tsed/socketio";

@SocketService("/nsp")
export class MyWS {

  @Nsp
  nsp: Namespace; // will inject SocketIO.Namespace (not available on constructor)

  @Nsp("/my-other-namespace")
  nspOther: Namespace; // communication between two namespace

  @Input("event")
  myMethod(@Namespace namespace: Namespace) {

  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16