diff --git a/.changeset/wild-coats-move.md b/.changeset/wild-coats-move.md new file mode 100644 index 0000000..adc823c --- /dev/null +++ b/.changeset/wild-coats-move.md @@ -0,0 +1,5 @@ +--- +"@soundxyz/redis-pubsub": minor +--- + +.publish can receive null or undefined and it skips the notification diff --git a/src/index.ts b/src/index.ts index f286462..c84b243 100644 --- a/src/index.ts +++ b/src/index.ts @@ -496,12 +496,14 @@ export function RedisPubSub({ async function publish( ...values: [ - { value: PublishInput; identifier?: string | number }, - ...{ value: PublishInput; identifier?: string | number }[], + { value: PublishInput | null | undefined; identifier?: string | number }, + ...{ value: PublishInput | null | undefined; identifier?: string | number }[], ] ) { await Promise.all( values.map(async ({ value, identifier }) => { + if (value == null) return; + const tracing = enabledLogEvents?.PUBLISH_MESSAGE_EXECUTION_TIME ? getTracing() : null; let parsedValue: ChannelData | SubscriberData;