Skip to content

Commit

Permalink
docs: Clarify what changed in minimal subscribe example between versi…
Browse files Browse the repository at this point in the history
…ons; #266
  • Loading branch information
empicano committed Jan 21, 2024
1 parent ec4fdb4 commit 13b44fb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
4 changes: 1 addition & 3 deletions docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ This documentation aims to cover everything you need to know to use aiomqtt in y

If you're new to MQTT, we recommend reading the [HiveMQ MQTT essentials](https://www.hivemq.com/mqtt-essentials/) guide as an introduction. Afterward, the [OASIS specification](https://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html) is a great reference. For asyncio, we recommend the [RealPython asyncio walkthrough](https://realpython.com/async-io-python/) as an introduction and the [asyncio docs](https://docs.python.org/3/library/asyncio.html) as a reference.

You're a big help if you open an issue or a pull request when you find an error or when you have an idea of how to improve these docs. It's easy to miss things that are unclear to newcomers when you're already familiar with the project. We need your fresh eyes here!

That said, let's dive in! 🤿
Thanks for being part of our community! ☀️
20 changes: 19 additions & 1 deletion docs/migration-guide-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,25 @@ asyncio.run(main())

The `filtered_messages`, `unfiltered_messages`, and `messages` methods have been removed and replaced with a single client-wide message queue.

A minimal example of printing all messages (unfiltered) looks like this:
For previous versions, a minimal example of printing all messages (unfiltered) looked like this:

```python
import asyncio
import aiomqtt


async def main():
async with aiomqtt.Client("test.mosquitto.org") as client:
await client.subscribe("temperature/#")
async with client.messages() as messages:
async for message in messages:
print(message.payload)


asyncio.run(main())
```

We now no longer need the line `async with client.messages() as messages:`, but instead access the message generator directly with `client.messages`:

```python
import asyncio
Expand Down
2 changes: 1 addition & 1 deletion docs/subscribing-to-a-topic.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ asyncio.run(main())
```

```{tip}
You can combine this idea with the one [from the previous section](#the-message-queue) to e.g. handle temperature in FIFO and humidity in LIFO order.
You can use [different queue types](#the-message-queue) for these queues to e.g. handle temperature in FIFO and humidity in LIFO order.
```

## Listening without blocking
Expand Down

0 comments on commit 13b44fb

Please sign in to comment.