teamhackback / hb-ddb

Vibe.d Async native D Postgres client
https://teamhackback.github.io/hb-ddb/docs/ddb/pg.html
1 stars 1 forks source link

Async notifications #3

Open wilzbach opened 7 years ago

wilzbach commented 7 years ago

listen, trigger

wilzbach commented 7 years ago

The following works now:

subscriber.subscribe("test1", "test2");
auto task = subscriber.listen((string channel, string message) {
    writefln("channel: %s, msg: %s", channel, message);
});

conn.publish("test1", "Hello World!");
conn.publish("test2", "Hello from Channel 2");

runTask({
    subscriber.subscribe("test-fiber");
    subscriber.publish("test-fiber", "Hello from the Fiber!");
    subscriber.unsubscribe();
});
channel: test1, msg: Hello World!
channel: test-fiber, msg: Hello from the Fiber!
channel: test2, msg: Hello from Channel 2