@typetron/websockets 0.3.2 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +27 -5
- package/package.json +2 -2
package/Readme.md
CHANGED
|
@@ -1,7 +1,29 @@
|
|
|
1
|
-
# Typetron
|
|
1
|
+
# Typetron WebSockets
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
This library is used to easily listen and emit WebSockets event
|
|
4
|
+
from the browser client to a Typetron app.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
#### Connecting to WebSockets
|
|
7
|
+
```ts
|
|
8
|
+
import { Websocket } from '@typetron/websockets'
|
|
9
|
+
export const socket = new Websocket('ws://localhost:8001')
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
#### Listening for events
|
|
14
|
+
```ts
|
|
15
|
+
socket.on('eventName').subscribe(response => {
|
|
16
|
+
console.log('Backend response', response)
|
|
17
|
+
})
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
#### Emitting events
|
|
21
|
+
```ts
|
|
22
|
+
socket.emit('eventName');
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
#### Emitting and listening for backend response
|
|
26
|
+
```ts
|
|
27
|
+
const users = await socket.request('users.list')
|
|
28
|
+
const savedUser = await socket.request('users.save', {name: 'John'})
|
|
29
|
+
```
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@typetron/websockets",
|
|
3
3
|
"description": "Typetron Websockets library",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.7",
|
|
6
6
|
"author": {
|
|
7
7
|
"email": "ionel@typetron.org",
|
|
8
8
|
"name": "Ionel Lupu"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"rxjs": "^6.6.7",
|
|
18
|
-
"@typetron/framework": "^0.3.
|
|
18
|
+
"@typetron/framework": "^0.3.7"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"typescript": "4.1.6"
|