Skip to content

Commit 26d3357

Browse files
committed
Added instructions for static imports.
Fixes obs-websocket-community-projects#182
1 parent 44aa9a2 commit 26d3357

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

README.md

+16-10
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,38 @@ Typescript definitions are included in this package, and are automatically gener
3434

3535
## Usage
3636
#### Instantiation
37-
The web distributable exposes a global named `OBSWebSocket`.
37+
The web distributable exposes a global named `OBSWebSocket`.
3838

3939
```html
4040
<script type='text/javascript' src='./dist/obs-websocket.js'></script>
4141
```
4242

43-
In node...
43+
In node...
4444

4545
```js
4646
const OBSWebSocket = require('obs-websocket-js');
4747
```
4848

49+
If you're working in a frontend framework and want to use static imports...
50+
51+
```js
52+
import OBSWebSocket from '../../node_modules/obs-websocket-js/lib/OBSWebSocket.js'; //relative path may vary depending on location of node_modules directory
53+
```
54+
4955
Create a new WebSocket connection using the following.
50-
- Address is optional; defaults to `localhost` with a port of `4444`.
51-
- Password is optional.
56+
- Address is optional; defaults to `localhost` with a port of `4444`.
57+
- Password is optional.
5258

5359
```js
5460
const obs = new OBSWebSocket();
5561
obs.connect({ address: 'localhost:4444', password: '$up3rSecretP@ssw0rd' });
5662
```
5763

5864
#### Sending Requests
59-
All requests support the following two Syntax options where both `err` and `data` will contain the raw response from the WebSocket plugin.
60-
_Note that all response objects will supply both the original [obs-websocket][link-obswebsocket] response items in their original format (ex: `'response-item'`), but also camelCased (ex: `'responseItem'`) for convenience._
61-
- RequestName must exactly match what is defined by the [`obs-websocket`][link-obswebsocket] plugin.
62-
- `{args}` are optional. Note that both `request-type` and `message-id` will be bound automatically.
65+
All requests support the following two Syntax options where both `err` and `data` will contain the raw response from the WebSocket plugin.
66+
_Note that all response objects will supply both the original [obs-websocket][link-obswebsocket] response items in their original format (ex: `'response-item'`), but also camelCased (ex: `'responseItem'`) for convenience._
67+
- RequestName must exactly match what is defined by the [`obs-websocket`][link-obswebsocket] plugin.
68+
- `{args}` are optional. Note that both `request-type` and `message-id` will be bound automatically.
6369
- To use callbacks instead of promises, use the `sendCallback` method instead of `send`.
6470

6571
```js
@@ -75,8 +81,8 @@ obs.disconnect();
7581
```
7682

7783
#### Receiving Events
78-
For all events, `data` will contain the raw response from the WebSocket plugin.
79-
_Note that all response objects will supply both the original [obs-websocket][link-obswebsocket] response items in their original format (ex: `'response-item'`), but also camelCased (ex: `'responseItem'`) for convenience._
84+
For all events, `data` will contain the raw response from the WebSocket plugin.
85+
_Note that all response objects will supply both the original [obs-websocket][link-obswebsocket] response items in their original format (ex: `'response-item'`), but also camelCased (ex: `'responseItem'`) for convenience._
8086
- EventName must exactly match what is defined by the [`obs-websocket`][link-obswebsocket] plugin.
8187

8288
```js

0 commit comments

Comments
 (0)