You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// To stop receiving, you can close the channel from within handler or check explicitly
79
79
if (msg.payload==='Hello World') {
@@ -92,10 +92,11 @@ await mesh.close();
92
92
```
93
93
94
94
### 6. Callback-based Backpressure
95
-
Mesh supports `onData(handler)` for consumers who prefer callbacks but need backpressure. The method returns a `Promise` that resolves when the stream is closed, allowing you to `await`the entire processing session.
95
+
Mesh supports `onData(handler)` for consumers who prefer callbacks but need backpressure. The method returns `void` (fire-and-forget), and the processing loop runs in the background.
96
96
97
97
```typescript
98
-
awaitchannel.onData(async (msg) => {
98
+
```typescript
99
+
channel.onData(async (msg) => {
99
100
await processMessage(msg);
100
101
// The next message is only requested after this line completes
Mesh supports `on_data(handler)` for consuming messages with backpressure. The method returns an `Awaitable` that resolves when the stream is closed, allowing you to `await`the entire processing session.
97
+
Mesh supports `on_data(handler)` for consuming messages with backpressure. The method returns `None` (fire-and-forget), and the processing loop runs in the background using `asyncio.create_task`.
95
98
96
99
```python
97
100
asyncdefhandler(msg):
98
101
await process_message(msg)
99
102
# The next message is consumed only after this function returns
0 commit comments