Skip to content

Commit f797712

Browse files
committed
docs: initial state constructor option
1 parent 0a79ba3 commit f797712

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

docs/api.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Note that creating a new session will immediately send the initial status code a
4141
|`keepAlive`|`number` \| `null`|`10000`|Time in milliseconds interval for the session to send a comment to keep the connection alive.<br><br>Give as `null` to disable the keep-alive mechanism.|
4242
|`statusCode`|`number`|`200`|Status code to be sent to the client.<br><br>Event stream requests can be redirected using HTTP 301 and 307 status codes. Make sure to set `Location` header when using these status codes (301/307) using the `headers` property.<br><br>A client can be asked to stop reconnecting by send a 204 status code.|
4343
|`headers`|`object`|`{}`|Additional headers to be sent along with the response.|
44+
|`state`|`object`|`{}`|Initial custom state for the session.<br><br>Accessed via the [`state`](#sessionstate-state) property.<br><br>When using TypeScript, providing the initial state structure allows the type of the `state` property to be automatically inferred.|
4445

4546
#### `Session#lastId`: `string`
4647

@@ -174,7 +175,13 @@ A `Channel` is used to broadcast events to many sessions at once.
174175
You may use the second generic argument `SessionState` to enforce that only sessions
175176
with the same state type may be registered with this channel.
176177

177-
#### `new Channel<State, SessionState>()`
178+
#### `new Channel<State, SessionState>([options = {}])`
179+
180+
`options` is an object with the following properties:
181+
182+
|Property|Type|Default|Description|
183+
|-|-|-|-|
184+
|`state`|`object`|`{}`|Initial custom state for the channel.<br><br>Accessed via the [`state`](#channelstate-state) property.<br><br>When using TypeScript, providing the initial state structure allows the type of the `state` property to be automatically inferred.|
178185

179186
#### `Channel#state`: `State`
180187

0 commit comments

Comments
 (0)