encore
encore copied to clipboard
PubSub Subscription doesn't work if provided as variable vs a string literal
I have a subscription whose identifier I've set as a constant, defined elsewhere.
The encore compiler doesn't allow me to do that because it checks whether the variable identifier matches the spec for the value its supposed to contain.
Example:
However, the value within that variable does conform to the spec expected by encore:
const pubSubSubscriptionName = "forum-post-tagger"
I see in the error message that it expects a string literal, but it would be nice if that can be passed as a variable as I like to keep constants like that defined in the same package to easily spot that eg two services have the same subscription name.
What's the use case for having "two services have the same subscription name"? A subscription can only be tied to a single service.
That's what I'm trying to avoid, which is why I prefer the constants route (stored in the same file) because that way, if I accidentally define a subscription twice for different services, it would be easier to spot the error.
Having said that, if Encore automatically detects duplicate subscriptions & errors out if so, then that is a viable solution as well.