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

onPrivateSubscribe "cb" arguments does not match type declaration #94

Closed
hastom opened this issue Sep 13, 2019 · 3 comments
Closed

onPrivateSubscribe "cb" arguments does not match type declaration #94

hastom opened this issue Sep 13, 2019 · 3 comments

Comments

@hastom
Copy link

hastom commented Sep 13, 2019

Centrifuge v2.2.2

According to declaration it should take one argument of interface SubscribePrivateResponse which has 2 props status and channels. So something like this should be valid:

...
onPrivateSubscribe: async ({ data }, cb) => {
  const { channels } = await getWsChannelTokens(data);
    cb({
      status: 200,
      channels: channels,
  });
},

But it will result in error TypeError: Cannot read property 'channels' of undefined because the actual thing its waiting for is

{
    status: 200,
    data: { channels: channels },
}

So I guess data property is missing in type declarations

@FZambia
Copy link
Member

FZambia commented Sep 16, 2019

@hastom hello, thanks for report. I will take a look soon - a bit busy these days.

@FZambia
Copy link
Member

FZambia commented Sep 18, 2019

Fixed in 7126410. In general current format is not beautiful at all as it requires passing status 200 to work which is a bit awkward, we should keep backwards compatibility for now, but in future releases I believe it needs to be improved.

@hastom
Copy link
Author

hastom commented Sep 18, 2019

Nice!

@hastom hastom closed this as completed Sep 18, 2019
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

No branches or pull requests

2 participants