Skip to content

Commit

Permalink
feat(types): rename RenderOptions -> RendererOptions (#3867)
Browse files Browse the repository at this point in the history
  • Loading branch information
samouss authored and Haroenv committed Oct 23, 2019
1 parent c3a7d69 commit 05c6f72
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/connectors/infinite-hits/connectInfiniteHits.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import escapeHits, { TAG_PLACEHOLDER } from '../../lib/escape-highlight';
import {
Renderer,
RenderOptions,
RendererOptions,
WidgetFactory,
Hits,
Unmounter,
Expand All @@ -22,16 +22,16 @@ export type InfiniteHitsConnectorParams = Partial<
InfiniteHitsRendererWidgetParams
>;

export interface InfiniteHitsRenderOptions<TInfiniteHitsWidgetParams>
extends RenderOptions<TInfiniteHitsWidgetParams> {
export interface InfiniteHitsRendererOptions<TInfiniteHitsWidgetParams>
extends RendererOptions<TInfiniteHitsWidgetParams> {
showPrevious: () => void;
showMore: () => void;
isFirstPage: boolean;
isLastPage: boolean;
}

export type InfiniteHitsRenderer<TInfiniteHitsWidgetParams> = Renderer<
InfiniteHitsRenderOptions<
InfiniteHitsRendererOptions<
InfiniteHitsConnectorParams & TInfiniteHitsWidgetParams
>
>;
Expand Down
8 changes: 4 additions & 4 deletions src/connectors/query-rules/connectQueryRules.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
Renderer,
RenderOptions,
RendererOptions,
WidgetFactory,
Helper,
HelperChangeEvent,
Expand Down Expand Up @@ -35,13 +35,13 @@ export type QueryRulesConnectorParams = {
transformItems?: ParamTransformItems;
};

export interface QueryRulesRenderOptions<TQueryRulesWidgetParams>
extends RenderOptions<TQueryRulesWidgetParams> {
export interface QueryRulesRendererOptions<TQueryRulesWidgetParams>
extends RendererOptions<TQueryRulesWidgetParams> {
items: any[];
}

export type QueryRulesRenderer<TQueryRulesWidgetParams> = Renderer<
QueryRulesRenderOptions<QueryRulesConnectorParams & TQueryRulesWidgetParams>
QueryRulesRendererOptions<QueryRulesConnectorParams & TQueryRulesWidgetParams>
>;

export type QueryRulesWidgetFactory<TQueryRulesWidgetParams> = WidgetFactory<
Expand Down
8 changes: 4 additions & 4 deletions src/connectors/voice-search/connectVoiceSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
createDocumentationMessageGenerator,
noop,
} from '../../lib/utils';
import { Renderer, RenderOptions, WidgetFactory } from '../../types';
import { Renderer, RendererOptions, WidgetFactory } from '../../types';
import createVoiceSearchHelper, {
VoiceListeningState,
ToggleListening,
Expand All @@ -18,16 +18,16 @@ export type VoiceSearchConnectorParams = {
searchAsYouSpeak?: boolean;
};

export interface VoiceSearchRenderOptions<TVoiceSearchWidgetParams>
extends RenderOptions<TVoiceSearchWidgetParams> {
export interface VoiceSearchRendererOptions<TVoiceSearchWidgetParams>
extends RendererOptions<TVoiceSearchWidgetParams> {
isBrowserSupported: boolean;
isListening: boolean;
toggleListening: ToggleListening;
voiceListeningState: VoiceListeningState;
}

export type VoiceSearchRenderer<TVoiceSearchWidgetParams> = Renderer<
VoiceSearchRenderOptions<
VoiceSearchRendererOptions<
VoiceSearchConnectorParams & TVoiceSearchWidgetParams
>
>;
Expand Down
10 changes: 5 additions & 5 deletions src/lib/insights/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
InsightsClientPayload,
InsightsClientWrapper,
Renderer,
RenderOptions,
RendererOptions,
Unmounter,
WidgetFactory,
SearchResults,
Expand Down Expand Up @@ -101,9 +101,9 @@ export default function withInsights(
connector: Connector<any>
): Connector<unknown> {
const wrapRenderFn = (
renderFn: Renderer<RenderOptions<unknown>>
): Renderer<RenderOptions<unknown>> => (
renderOptions: RenderOptions,
renderFn: Renderer<RendererOptions<unknown>>
): Renderer<RendererOptions<unknown>> => (
renderOptions: RendererOptions,
isFirstRender: boolean
) => {
const { results, hits, instantSearchInstance } = renderOptions;
Expand All @@ -123,6 +123,6 @@ export default function withInsights(
return renderFn(renderOptions, isFirstRender);
};

return (renderFn: Renderer<RenderOptions<unknown>>, unmountFn: Unmounter) =>
return (renderFn: Renderer<RendererOptions<unknown>>, unmountFn: Unmounter) =>
connector(wrapRenderFn(renderFn), unmountFn);
}
4 changes: 2 additions & 2 deletions src/types/connector.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Hits, InstantSearch, SearchResults } from './instantsearch';
import { InsightsClient } from './insights';

export type RenderOptions<TWidgetParams = unknown> = {
export type RendererOptions<TWidgetParams = unknown> = {
widgetParams: TWidgetParams;
instantSearchInstance: InstantSearch;
results?: SearchResults;
hits?: Hits;
insights?: InsightsClient;
};

export type Renderer<TRenderOptions extends RenderOptions = any> = (
export type Renderer<TRenderOptions extends RendererOptions = any> = (
renderOptions: TRenderOptions,
isFirstRender: boolean
) => void;
Expand Down

0 comments on commit 05c6f72

Please sign in to comment.