Open bananabr opened 5 years ago
Hi @bananabr , I'm not sure I'm seeing how that would work. If the function is asynchronous, does it go ahead and try to establish a connection before the promise has resolved?
No, it should not. I need to present a JWT for my connection to be established. To get the token I need I use a service that requests the token asynchronously from my OpenID provider. No problem getting the fist token, I can wait for it and then pass it as a connection header or query param, but it needs to be refreshed once in a while and I could figure out how to make this work with the current version of angular2-actioncable.
That seems like a similar problem to the one that prompted me to add the ability to use a callback to get the params. I use the angular token auth package which by default generates a new auth token for every request. So my cable connection call looks like this:
this.cableService.cable('example.com/cable', () => this.tokenService.currentAuthData)
In the case of a disconnect, the function will be re-evaluated to get the fresh authentication params.
That seems like a similar problem to the one that prompted me to add the ability to use a callback to get the params. I use the angular token auth package which by default generates a new auth token for every request. So my cable connection call looks like this:
this.cableService.cable('example.com/cable', () => this.tokenService.currentAuthData)
In the case of a disconnect, the function will be re-evaluated to get the fresh authentication params.
Is this really possible? I just tried it but the same token (frist one) is being sent.
Hi,
Cable's constructor already permits params to be a Function, but this function must be synchronous. It would really help if params could return a Promise.
Thanks in advance