@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.
Files changed (2) hide show
  1. package/Readme.md +27 -5
  2. package/package.json +2 -2
package/Readme.md CHANGED
@@ -1,7 +1,29 @@
1
- # Typetron Angular utilities
1
+ # Typetron WebSockets
2
2
 
3
- **[Typetron](https://typetron.org)** is a **modern web framework** built for Node.js, written in **Typescript**, that
4
- allows you to build fully featured web applications.
3
+ This library is used to easily listen and emit WebSockets event
4
+ from the browser client to a Typetron app.
5
5
 
6
- This package contains a set of utilities used in frontend apps when working with Typetron in order to easily connect to
7
- websockets. More about it at [https://typetron.org](https://typetron.org/frontend/websockets)
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.2",
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.4"
18
+ "@typetron/framework": "^0.3.7"
19
19
  },
20
20
  "devDependencies": {
21
21
  "typescript": "4.1.6"