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

Don't trigger autorefresh when autofetch false #30405

Merged
merged 1 commit into from
Feb 7, 2019
Merged
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
13 changes: 8 additions & 5 deletions src/ui/public/visualize/loader/embedded_visualize_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class EmbeddedVisualizeHandler {
timeRange,
filters,
query,
autoFetch,
autoFetch = true,
Private,
} = params;

Expand All @@ -127,8 +127,6 @@ export class EmbeddedVisualizeHandler {
forceFetch: false,
};

this.autoFetch = !(autoFetch === false);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used a default value up, to make that a bit better readable.


// Listen to the first RENDER_COMPLETE_EVENT to resolve this promise
this.firstRenderComplete = new Promise(resolve => {
this.listeners.once(RENDER_COMPLETE_EVENT, resolve);
Expand All @@ -138,6 +136,7 @@ export class EmbeddedVisualizeHandler {
element.setAttribute(RENDERING_COUNT_ATTRIBUTE, '0');
element.addEventListener('renderComplete', this.onRenderCompleteListener);

this.autoFetch = autoFetch;
this.appState = appState;
this.vis = vis;
if (uiState) {
Expand All @@ -154,7 +153,9 @@ export class EmbeddedVisualizeHandler {
this.vis.on('update', this.handleVisUpdate);
this.vis.on('reload', this.reload);
this.uiState.on('change', this.onUiStateChange);
timefilter.on('autoRefreshFetch', this.reload);
if (autoFetch) {
timefilter.on('autoRefreshFetch', this.reload);
}

this.dataLoader = EmbeddedVisualizeHandler.__ENABLE_PIPELINE_DATA_LOADER__
? new PipelineDataLoader(vis)
Expand Down Expand Up @@ -236,7 +237,9 @@ export class EmbeddedVisualizeHandler {
public destroy(): void {
this.destroyed = true;
this.debouncedFetchAndRender.cancel();
timefilter.off('autoRefreshFetch', this.reload);
if (this.autoFetch) {
timefilter.off('autoRefreshFetch', this.reload);
}
this.vis.removeListener('reload', this.reload);
this.vis.removeListener('update', this.handleVisUpdate);
this.element.removeEventListener('renderComplete', this.onRenderCompleteListener);
Expand Down
6 changes: 6 additions & 0 deletions src/ui/public/visualize/loader/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ export interface VisualizeLoaderParams {
* global AppState.
*/
appState?: AppState;
/**
* Whether or not the visualization should fetch its data automatically. If this is
* set to `false` the loader won't trigger a fetch on embedding or when an auto refresh
* cycle happens. Default value: `true`
*/
autoFetch?: boolean;
}

/**
Expand Down