@@ -241,26 +241,26 @@ delete cancelator; // cancels the in-flight query; co_await resumes with an erro
241241
242242### Notifications (Postgres only)
243243
244- Subscribe to a channel and connect to the driver signal to receive payloads . If the connection drops, re-subscribe after reconnecting:
244+ Subscribe with a per- channel callback . If the connection drops, re-subscribe after reconnecting:
245245
246246``` c++
247247ADatabase db;
248248QObject receiver;
249249
250- connect (db.driver(), &ADriver::notificationReceived, &receiver,
251- [ ] (const ADatabaseNotification ¬ification) {
252- qDebug() << "DB notification:" << notification.self << notification.name
253- << notification.payload;
254- });
255-
256250connect (db.driver(), &ADriver::stateChanged, &receiver,
257251 [ &db] (ADatabase::State state, const QString &status) {
258252 qDebug() << "state changed" << state << status << db.isOpen();
259253
260254 if (state == ADatabase::Disconnected) {
261255 qDebug() << "state disconnected";
262256 } else if (state == ADatabase::Connected) {
263- db.subscribeToNotification(u"my_awesome_notification"_s, &receiver);
257+ db.subscribeToNotification(
258+ u"my_awesome_notification"_s,
259+ &receiver,
260+ [](const ADatabaseNotification ¬ification) {
261+ qDebug() << "DB notification:" << notification.self
262+ << notification.name << notification.payload;
263+ });
264264 }
265265 });
266266
0 commit comments