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

Improve behavior for realtime channel creation and improve docs #831

Merged
merged 6 commits into from
Jan 12, 2025

Conversation

jan-tennert
Copy link
Collaborator

@jan-tennert jan-tennert commented Jan 10, 2025

What kind of change does this PR introduce?

Docs update / Improvement (closes #818)

What is the current behavior?

Calling Realtime#channel() will always create a new channel and override the existing one, if there is one by the given channel id. Also the docs are not very clear.

What is the new behavior?

  • Realtime#channel() will now also return an existing channel, if there is one.
  • The internal implementation and the docs have also been improved.

@jan-tennert jan-tennert added the enhancement New feature or request label Jan 10, 2025
@jan-tennert jan-tennert self-assigned this Jan 10, 2025
@grdsdev
Copy link
Contributor

grdsdev commented Jan 10, 2025

Hi @jan-tennert this isn't how realtime-js works, on js it can exist multiple channels for the same topic, as its hold by an array.

Tho I do think that the behavior of not having duplicate channels should be the correct, I'm not sure why it is that way, so tagging @filipecabaco for discussion.

Copy link
Contributor

@grdsdev grdsdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blocking until correct behavior is discussed

@jan-tennert
Copy link
Collaborator Author

Hi @jan-tennert this isn't how realtime-js works, on js it can exist multiple channels for the same topic, as its hold by an array.

Tho I do think that the behavior of not having duplicate channels should be the correct, I'm not sure why it is that way, so tagging @filipecabaco for discussion.

Yea, I saw that, was actually going to ask about this because the Swift V2 Code also uses a map instead of an array

@grdsdev
Copy link
Contributor

grdsdev commented Jan 10, 2025

Yes @jan-tennert Swift follows Kotlin's behavior, which is also not aligned with JS.

@filipecabaco
Copy link

Swift and Kotlin are more correct. We should do the same on JS as when you subscribe to a topic it should have a "unique" name so this looks like a bug from realtime-js 🤔

@grdsdev grdsdev self-requested a review January 10, 2025 18:02
Copy link
Contributor

@grdsdev grdsdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved as Filipe confirmed this is the correct behavior, I'll do the same for Swift.

Just not sure we can do the fix on JS as it seems it will be a breaking change.

@jan-tennert jan-tennert merged commit 6956309 into master Jan 12, 2025
13 checks passed
@jan-tennert jan-tennert deleted the realtime-channel branch January 12, 2025 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request realtime tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Realtime - Subscribing to the same channel id causes upstream closes / unexpected behavior.
3 participants