I Have two types of dynamic channel ids:
I'm trying to create two PubNub After-Publish-Or-Fire Functions:
The problem is that it seems that PubNub cannot support two functions on a same channel. and event types
My questions:
You want to reuse code in two event handlers. You provided your own answer. Your answer is an acceptable approach in your original question. And we have provided an additional way you may consider for solving this.
public.*
channels.private.*
channels.You can create a log
channel which is invoked by a fire. Inside the public.*
and private.*
functions you will trigger a fire invoking the log
channel event handler. This way you have shared code reuse for your logging mechanism.
Question: Are both
Before-Publish-Or-Fire
andAfter-Publish-Or-Fire
events async?Answer: No. Only
on-after
events are async.
A natural way to think about this is that anything that needs to happen before
must be blocking and non-async. Otherwise it couldn't happen before, and may end up happening after.
Question: Can you use the
Before-Publish-Or-Fire
for the BOT function andAfter-Publish-Or-Fire
for Logging)?Answer: Yes! This is a great way to do it.