Skip to content

Commit

Permalink
.publish can receive null or undefined (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloSzx committed Jul 21, 2023
1 parent 5a2ef82 commit 69f7422
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/wild-coats-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@soundxyz/redis-pubsub": minor
---

.publish can receive null or undefined and it skips the notification
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 69f7422

Please sign in to comment.