react-native
react-native copied to clipboard
[6.0] Support web socket channel
Is your feature request related to a problem? Please describe.
Support channel as web socket channel in Preview. We use web socket server to integrate with quite a few tools, it will be helpful if we can continue to support this.
Describe the solution you'd like
Since it's already implemented in v5, we can continue to use the same interface e.g. disableWebsockets, host, port.
Describe alternatives you've considered
No alternatives yet, as far as I know
Are you able to assist bring the feature to reality?
Yes, I'd be happy to. I can follow implementation in v5. But I found some method is not supported in v6 such as this._stories.setChannel, might need you guys advise on this.
Additional context
These are some package/tools I used that rely on websocket
- https://github.com/oblador/loki
- https://github.com/orta/vscode-react-native-storybooks
@nutstick Hey thanks for offering to help! That would be great actually, coincidentally I was actually trying to figure out how to do this today. The problem like you were getting at here is a lot of the apis have actually changed between 5.3 and 6.0 and it's been a bit difficult to get something working. If you like I could put what I currently have into a branch, maybe it can help. By the way this._stories.setChannel is done via the addons package now addons.setChannel(channel); and is already in 6.0 in Preview.tsx code.
I've said it before but just to be clear I do intend to bring back this feature and the server in some way I just haven't been able to find a good way to do it yet. Also I don't know the server implementation at all really since it was made a long time ago by someone else. Recently I've been trying to figure it out but I'm still at the beginning of that.
@nutstick I've made a branch with some experiments, not much there but it might be useful: https://github.com/storybookjs/react-native/commit/03160323857301f901e1d2e1e0039f8e0923e4b0
Thanks for quick reply! Amazing let me try this out
Hi @dannyhw sorry for late reply, I have try out your branch. Seems it's not working yet. But from the code look like we didn't call addons.setChannel(channel); when create new channel. After I add this, I can change selected story.
But I notice that the SET_STORIES is not fired if I only run addons.setChannel. Not sure if it's expected?
@nutstick yeah the branch wasn't working but it's just part of the changes needed. I just hadn't figured everything out yet. You're right I think I forgot to add the set channel thing. Not sure about the set stories thing I'd have to take another look at it.
I was able to get the server working with a bit of help and some hacks https://github.com/storybookjs/react-native/pull/393
Its not ready yet but if you want to follow progress you can check this PR
This was done already so im closing this.