@leancodepl/rx-pipe-client 9.6.5 → 9.6.6
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 +21 -21
- package/index.cjs.js +2 -2
- package/index.esm.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,8 +31,8 @@ import { mkPipeClient } from "@leancodepl/rx-pipe-client"
|
|
|
31
31
|
import { createPipe } from "@leancodepl/pipe"
|
|
32
32
|
|
|
33
33
|
const pipe = createPipe({
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
url: "wss://api.example.com/pipe",
|
|
35
|
+
getAccessToken: () => localStorage.getItem("token"),
|
|
36
36
|
})
|
|
37
37
|
|
|
38
38
|
const pipeClient = mkPipeClient({ pipe })
|
|
@@ -45,28 +45,28 @@ import { mkPipeClient } from "@leancodepl/rx-pipe-client"
|
|
|
45
45
|
import { createPipe } from "@leancodepl/pipe"
|
|
46
46
|
|
|
47
47
|
interface ChatTopic {
|
|
48
|
-
|
|
48
|
+
roomId: string
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
interface ChatNotifications {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
MessageReceived: {
|
|
53
|
+
id: string
|
|
54
|
+
content: string
|
|
55
|
+
authorId: string
|
|
56
|
+
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
const pipe = createPipe({
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
url: "wss://api.example.com/pipe",
|
|
61
|
+
getAccessToken: () => localStorage.getItem("token"),
|
|
62
62
|
})
|
|
63
63
|
const pipeClient = mkPipeClient({ pipe })
|
|
64
64
|
const chatTopic = pipeClient.createTopic<ChatTopic, ChatNotifications>("chat")
|
|
65
65
|
|
|
66
66
|
chatTopic({ roomId: "room1" }).subscribe(notification => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
if (notification.type === "MessageReceived") {
|
|
68
|
+
console.log(`New message: ${notification.data.content}`)
|
|
69
|
+
}
|
|
70
70
|
})
|
|
71
71
|
```
|
|
72
72
|
|
|
@@ -78,27 +78,27 @@ import { mkPipeClient } from "@leancodepl/rx-pipe-client"
|
|
|
78
78
|
import { createPipe } from "@leancodepl/pipe"
|
|
79
79
|
|
|
80
80
|
interface MetricsTopic {
|
|
81
|
-
|
|
81
|
+
dashboardId: string
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
interface MetricsNotifications {
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
CpuUpdate: { value: number }
|
|
86
|
+
MemoryUpdate: { value: number }
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
const pipe = createPipe({
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
url: "wss://api.example.com/pipe",
|
|
91
|
+
getAccessToken: () => localStorage.getItem("token"),
|
|
92
92
|
})
|
|
93
93
|
const pipeClient = mkPipeClient({ pipe })
|
|
94
94
|
const metricsTopic = pipeClient.createTopic<MetricsTopic, MetricsNotifications>("metrics")
|
|
95
95
|
|
|
96
96
|
const cpuUpdates$ = metricsTopic({ dashboardId: "main" }).pipe(
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
filter(notification => notification.type === "CpuUpdate"),
|
|
98
|
+
map(notification => notification.data.value),
|
|
99
99
|
)
|
|
100
100
|
|
|
101
101
|
cpuUpdates$.subscribe(value => {
|
|
102
|
-
|
|
102
|
+
console.log(`CPU: ${value}%`)
|
|
103
103
|
})
|
|
104
104
|
```
|
package/index.cjs.js
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Creates RxJS-based topic functions for real-time data subscriptions using "@leancodepl/pipe".
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* @param pipe - Pipe instance from "@leancodepl/pipe"
|
|
7
7
|
* @returns Object containing `createTopic` method for creating typed observables
|
|
8
8
|
* @example
|
|
9
9
|
* ```typescript
|
|
10
10
|
* const pipe = createPipe({ url: 'wss://api.example.com/pipe' });
|
|
11
11
|
* const pipeClient = mkPipeClient({ pipe });
|
|
12
|
-
*
|
|
12
|
+
*
|
|
13
13
|
* const chatTopic = pipeClient.createTopic('chat');
|
|
14
14
|
* const messages$ = chatTopic({ roomId: 'room1' });
|
|
15
15
|
* ```
|
package/index.esm.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Creates RxJS-based topic functions for real-time data subscriptions using "@leancodepl/pipe".
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* @param pipe - Pipe instance from "@leancodepl/pipe"
|
|
5
5
|
* @returns Object containing `createTopic` method for creating typed observables
|
|
6
6
|
* @example
|
|
7
7
|
* ```typescript
|
|
8
8
|
* const pipe = createPipe({ url: 'wss://api.example.com/pipe' });
|
|
9
9
|
* const pipeClient = mkPipeClient({ pipe });
|
|
10
|
-
*
|
|
10
|
+
*
|
|
11
11
|
* const chatTopic = pipeClient.createTopic('chat');
|
|
12
12
|
* const messages$ = chatTopic({ roomId: 'room1' });
|
|
13
13
|
* ```
|