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

RN Disables websockets when using onDeviceUI #3278

Closed
wants to merge 4 commits into from

Conversation

Gongreg
Copy link
Member

@Gongreg Gongreg commented Mar 24, 2018

This change will by default disable websockets when using onDeviceUI.
I've also added option enable websockets back.

Issue is #3271

There are few questions that I have:

  1. Do we need the option in the first place. Is there anybody using onDeviceUI with websockets. Can we brake it for them? Should we brake it?

  2. If we keep the option where it should be documented.

  3. There is an increasing need to add tests for RN part.

  4. Where is resetStorybook option used at all? What does it bring. Why would we want to reset channel if it already exists?

@danielduan
Copy link
Member

Breaking this would basically disable all addons by default right? Since our addons don’t run inside the device UI?

I’m definitely in support of just removing it permanently instead of keeping it as an option. It will make maintaining a lot easier. Wondering if we can get some usage data.

@Gongreg
Copy link
Member Author

Gongreg commented Mar 24, 2018

You are correct, if we implement is and user is using onDeviceUI the addons would be disabled (unless he specifically says useWebsockets in options.

Nonetheless the current implementation I've done in our app is to simply check whether storybook is running with simple fetch.

Something like

  fetch('http://localhost:7007')
	.then(() => this.setState({UI: getStorybook()}))
    .catch(() => this.setState({UI: getStorybook(..., {onDeviceUI: true})}));

So if server is running onDeviceUI is disabled and addons work, if server is down, it simply displays stories without any addons.

And one of the next steps I think we should try to achieve is running addons on the device. It is definitely possible, we just need to think about the way to do it.

@danielduan
Copy link
Member

Maybe we can put that fetch test as a default in the getstorybook cli template?

@Gongreg
Copy link
Member Author

Gongreg commented Mar 24, 2018

It could be added I guess, just need to think what about port/host? Should we do separate PR for it?

@danielduan
Copy link
Member

That’s probably a better idea

Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

This change makes sense to me, and I like that it's still possible to use plugins if you depend on them.

Can we document the useWebsockets option as part of this PR, and also document the fact that after this PR, onDeviceUI will make the native storybook standalone unless you specify useWebsockets? Since it's a big breaking change, it needs a documentation update, both in the normal docs and also in the migration guide (assuming this is a 4.0 feature)

@f0rr0
Copy link

f0rr0 commented Mar 27, 2018

I was able to get a standalone build working without changing anything in the storybook source. I'm assuming not having a server running throws errors but they are silently consumed? I'm using haul packager though

@codecov
Copy link

codecov bot commented Mar 30, 2018

Codecov Report

Merging #3278 into master will decrease coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3278      +/-   ##
==========================================
- Coverage   36.82%   36.81%   -0.02%     
==========================================
  Files         458      458              
  Lines       10033    10036       +3     
  Branches      892      896       +4     
==========================================
  Hits         3695     3695              
- Misses       5782     5794      +12     
+ Partials      556      547       -9
Impacted Files Coverage Δ
app/react-native/src/preview/index.js 0% <0%> (ø) ⬆️
addons/knobs/src/angular/utils.js 82.14% <0%> (ø) ⬆️
app/react-native/src/bin/storybook-start.js 0% <0%> (ø) ⬆️
addons/knobs/src/components/types/Number.js 7.46% <0%> (ø) ⬆️
addons/info/src/components/PropVal.js 84.25% <0%> (ø) ⬆️
addons/storysource/src/loader/parsers/parser-js.js 14.28% <0%> (ø) ⬆️
lib/ui/src/libs/key_events.js 33.96% <0%> (ø) ⬆️
.../viewport/src/manager/components/SelectViewport.js 18.18% <0%> (ø) ⬆️
lib/core/src/client/preview/reducer.js 37.5% <0%> (ø) ⬆️
addons/knobs/src/components/PropForm.js 9.3% <0%> (ø) ⬆️
... and 69 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7342707...e31070f. Read the comment docs.

Allows to set events beforehand.
@danielduan
Copy link
Member

@f0rr0 do you have a public repo somewhere where you are running Storybook RN without the web UI?

@stale
Copy link

stale bot commented Apr 26, 2018

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Apr 26, 2018
@rmevans9
Copy link
Contributor

@f0rr0 It depends on platform too. I think on iOS if the websocket connection fails it just silently eats that error but Android makes a lot of noise (red boxes) if it fails.

@stale stale bot removed the inactive label Apr 26, 2018
@stale
Copy link

stale bot commented May 17, 2018

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label May 17, 2018
@Gongreg
Copy link
Member Author

Gongreg commented May 18, 2018

Still relevant.

@stale stale bot removed the inactive label May 18, 2018
@Hypnosphi Hypnosphi added the todo label May 19, 2018
@Gongreg Gongreg closed this May 23, 2018
@Gongreg Gongreg deleted the onDeviceUISkipWebsockets branch October 10, 2018 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants