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

📜[storysource] 📦 [sandpack] The clientApi must be reused when possible #6154

Merged
merged 1 commit into from
Apr 2, 2019

Conversation

libetl
Copy link
Member

@libetl libetl commented Mar 18, 2019

Issue:

What I did

I am working on a topic : ability to live edit the story when on the screen, and ability to export the component as a project in codesandbox.
This will be done by upgrading the storysource addon, which could become an Integrated Development Environment

Sandpack will re-download storybook.
Then we must have an idempotent behavior, which means keeping control over code run several times.
In this case, we must prevent the clientApi from being created twice, instead we must reuse the currently existing one.

How to test

  • Is this testable with Jest or Chromatic screenshots?
    I added one test to verify that it works.

  • Does this need a new example in the kitchen sink apps?
    I don't think so.

  • Does this need an update to the documentation?
    I don't think so.

If your answer is yes to any of these, please make sure to include it in your PR.

@libetl
Copy link
Member Author

libetl commented Mar 18, 2019

Hi @shilman @tmeasday and @ndelangen.

I think I spoke about it with you, but don't hesitate to discuss about the intent if you don't agree.
Any better answer is welcome.

@codecov
Copy link

codecov bot commented Mar 18, 2019

Codecov Report

Merging #6154 into next will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##             next    #6154      +/-   ##
==========================================
+ Coverage   38.04%   38.06%   +0.01%     
==========================================
  Files         643      643              
  Lines        9420     9423       +3     
  Branches     1373     1345      -28     
==========================================
+ Hits         3584     3587       +3     
  Misses       5268     5268              
  Partials      568      568
Impacted Files Coverage Δ
lib/core/src/client/preview/start.js 73.86% <100%> (+0.92%) ⬆️

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 7c7ecbb...cc8f843. Read the comment docs.

const storyStore = new StoryStore({ channel });
const clientApi = new ClientApi({ storyStore, decorateStory });
let storyStore;
let clientApi;
Copy link
Member Author

Choose a reason for hiding this comment

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

any way to make that const again ?
I know that Kotlin can do it. (free ad)

Copy link
Member

Choose a reason for hiding this comment

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

I'd wrap it into a function, that way the result of the function can be a const

Copy link
Member

@tmeasday tmeasday left a comment

Choose a reason for hiding this comment

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

LGTM

@libetl libetl added this to the v5.1.0 milestone Mar 20, 2019
@libetl
Copy link
Member Author

libetl commented Apr 2, 2019

@shilman, @ndelangen ?
image

@ndelangen ndelangen merged commit ff25b5c into next Apr 2, 2019
@ndelangen ndelangen deleted the storysource/reuse-currently-built-client-api branch April 2, 2019 15:08
@libetl
Copy link
Member Author

libetl commented Apr 2, 2019

thanks

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.

3 participants