@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
41 lines (27 loc) • 1.02 kB
Markdown
lang: en
title: 'API docs: socketio.socketio.subscribe'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/extensions/socketio
permalink: /doc/en/lb4/apidocs.socketio.socketio.subscribe.html
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/socketio](./socketio.md) > [socketio](./socketio.socketio.md) > [subscribe](./socketio.socketio.subscribe.md)
## socketio.subscribe() function
Decorate a method to subscribe to socketio events. For example,
```ts
@socketio.subscribe('chat message')
async function onChat(msg: string) {
}
```
<b>Signature:</b>
```typescript
function subscribe(...messageTypes: (string | RegExp)[]): MethodDecorator;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| messageTypes | (string \| RegExp)\[\] | |
<b>Returns:</b>
MethodDecorator