diff --git a/README.md b/README.md index b4de01dd1c..d22013328c 100644 --- a/README.md +++ b/README.md @@ -296,15 +296,15 @@ Check out the [Clustering Guide](./docs/clustering.md) when using Node Redis to The Node Redis client class is an Nodejs EventEmitter and it emits an event each time the network status changes: -| Event name | Scenes | Parameters | -|--------------|-------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------| -| connect | The client is initiating a connection to the server. | _undefined_ | -| ready | The client successfully initiated the connection to the server. | _undefined_ | -| end | The client disconnected the connection to the server via `.quit()` or `.disconnect()`. | _undefined_ | -| error | When a network error has occurred, such as unable to connect to the server or the connection closed unexpectedly. | The error object, such as `SocketClosedUnexpectedlyError: Socket closed unexpectedly` or `Error: connect ECONNREFUSED [IP]:[PORT]` | -| reconnecting | The client is trying to reconnect to the server. | _undefined_ | +| Event name | Scenes | Arguments to be passed to the listener | +|----------------|-------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------| +| `connect` | The client is initiating a connection to the server. | _No argument_ | +| `ready` | The client successfully initiated the connection to the server. | _No argument_ | +| `end` | The client disconnected the connection to the server via `.quit()` or `.disconnect()`. | _No argument_ | +| `error` | When a network error has occurred, such as unable to connect to the server or the connection closed unexpectedly. | 1 argument: The error object, such as `SocketClosedUnexpectedlyError: Socket closed unexpectedly` or `Error: connect ECONNREFUSED [IP]:[PORT]` | +| `reconnecting` | The client is trying to reconnect to the server. | _No argument_ | -The client will not emit any other events beyond those listed above. +The client will not emit [any other events](./docs/v3-to-v4.md#all-the-removed-events) beyond those listed above. ## Supported Redis versions diff --git a/docs/v3-to-v4.md b/docs/v3-to-v4.md index 3ef43444c8..834b02141c 100644 --- a/docs/v3-to-v4.md +++ b/docs/v3-to-v4.md @@ -28,15 +28,31 @@ await client.connect(); await client.ping(); ``` -### No `message` event +### All the removed events -In V4, you don't need to add listener to the `message` and `message_buffer` events, you can get the message directly in `subscribe`-like commands. +The following events that existed in V3 were removed in V4: + +1. `warning` +2. `subscribe` +3. `psubscribe` +4. `unsubscribe` +5. `message` +6. `message_buffer` +7. `messageBuffer` +8. `pmessage` +9. `pmessage_buffer` +10. `pmessageBuffer` +11. `monitor` + +#### No `message`-like event + +In V4, you don't need to add a listener to the `message`-like events (items 5 to 10 of the above list), you can get the message directly in `subscribe`-like commands. The second argument of these commands is a callback, which will be triggered every time there is a message published to the channel. The third argument to these commands is a boolean to set `bufferMode` (default `false`). If it's set to `true` you will receive a buffer instead of a string. -The `subscribe`-like commands return a promise. If the server returns `ok` the promise will be fulfilled, otherwise the promise will be rejected. +The `subscribe`-like commands return a promise. If the command is executed successfully the promise will be fulfilled, otherwise the promise will be rejected. ```typescript import { createClient } from 'redis';