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

(#1736) Expose forceReRender over channel [WIP] #2600

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/angular/src/client/preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ const storyStore = new StoryStore();
const reduxStore = createStore(reducer);
const context = { storyStore, reduxStore };

let channel;
if (isBrowser) {
const queryParams = qs.parse(window.location.search.substring(1));
const channel = createChannel({ page: 'preview' });
channel = createChannel({ page: 'preview' });
channel.on('setCurrentStory', data => {
reduxStore.dispatch(selectStory(data.kind, data.story));
});
Expand Down Expand Up @@ -55,3 +56,10 @@ const renderUI = () => {
reduxStore.subscribe(renderUI);

export const forceReRender = () => render(context, true);

if (isBrowser) {
channel.on('forceReRender', () => {
console.log('force ReRender'); // Remove before merging
forceReRender();
});
}
10 changes: 9 additions & 1 deletion app/react/src/client/preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ const reduxStore = createStore(reducer);
/* eslint-enable */
const context = { storyStore, reduxStore };

let channel;
if (isBrowser) {
const queryParams = qs.parse(window.location.search.substring(1));
const channel = createChannel({ page: 'preview' });
channel = createChannel({ page: 'preview' });
channel.on('setCurrentStory', data => {
reduxStore.dispatch(selectStory(data.kind, data.story));
});
Expand Down Expand Up @@ -58,3 +59,10 @@ const renderUI = () => {
reduxStore.subscribe(renderUI);

export const forceReRender = () => render(context, true);

if (isBrowser) {
channel.on('forceReRender', () => {
console.log('force ReRender'); // Remove before merging
forceReRender();
});
}
10 changes: 9 additions & 1 deletion app/vue/src/client/preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ const storyStore = new StoryStore();
const reduxStore = createStore(reducer);
const context = { storyStore, reduxStore };

let channel;
if (isBrowser) {
const queryParams = qs.parse(window.location.search.substring(1));
const channel = createChannel({ page: 'preview' });
channel = createChannel({ page: 'preview' });
channel.on('setCurrentStory', data => {
reduxStore.dispatch(selectStory(data.kind, data.story));
});
Expand Down Expand Up @@ -56,3 +57,10 @@ const renderUI = () => {
reduxStore.subscribe(renderUI);

export const forceReRender = () => render(context, true);

if (isBrowser) {
channel.on('forceReRender', () => {
console.log('force ReRender'); // Remove before merging
forceReRender();
});
}
4 changes: 4 additions & 0 deletions lib/addons/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export class AddonStore {
.map(name => this.loaders[name])
.forEach(loader => loader(api));
}

forceReRender() {
this.getChannel().emit('forceReRender'); // accessing this.channel via this.getChannel gives us validation
}
}

export default new AddonStore();