Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support multiple handlers for a single subscription #66

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

jonahsnider
Copy link

@jonahsnider jonahsnider commented Jul 2, 2024

πŸ”— Linked issue

Closes #65

❓ Type of change

  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Allows adding multiple handlers to a single channel subscription.
The old API will still work. A new API was added for removing specific handlers without fully unsubscribing from the channel:

const handler1 = () => { /* ... */ };

// start subscription
await redis.subscribe('users/123', handler1);

const handler2 = () => { /* ... */ }; 

// use the existing subscription
await redis.subscribe('users/123', handler2);

// remove handler1, keep subscription alive
await redis.unsubscribe('users/123', handler1);

// no more handlers for channel, close subscription
await redis.unsubscribe('users/123', handler2);

To avoid introducing any breaking changes, the errors in errors.ts were marked @deprecated, since they are no longer relevant with the introduction of this feature.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support multiple subscriptions to one Redis channel
1 participant