Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

feat(InfiniteHits): support cache #804

Merged
merged 3 commits into from
Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions src/components/InfiniteHits.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,18 @@ export default {
return items;
},
},
cache: {
type: Object,
default: undefined,
},
},
computed: {
widgetParams() {
return {
showPrevious: this.showPrevious,
escapeHTML: this.escapeHTML,
transformItems: this.transformItems,
cache: this.cache,
Haroenv marked this conversation as resolved.
Show resolved Hide resolved
};
},
items() {
Expand Down
14 changes: 14 additions & 0 deletions stories/InfiniteHits.stories.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { storiesOf } from '@storybook/vue';
import { action } from '@storybook/addon-actions';
import { createInfiniteHitsSessionStorageCache } from 'instantsearch.js/es/lib/infiniteHitsCache';
Copy link
Member

Choose a reason for hiding this comment

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

Should we reexport createInfiniteHitsSessionStorageCache from vue-instantsearch?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's an interesting idea, but we don't do that for now for other things like router, I'm not sure if that can have a bundle size impact?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it'll have a bundle size impact but it's worth trying.

On a UX perspective, it doesn't make sense to import something from a library's dependency (you're not even aware that you use instantsearch.js when you use vue-instantsearch).

Copy link
Contributor

Choose a reason for hiding this comment

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

let's do it in a stacked PR? There's argument for exposing the connectors etc. too, so let's join that?

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 guess not in a stacked PR but a separate PR as in something like chore: reexport things from IS.js...

If we're going to reexport stuff, then we'd better do them altogether with doc changes.
What do you think?

import { simple } from 'instantsearch.js/es/lib/stateMappings';
import { previewWrapper } from './utils';
import { MemoryRouter } from './MemoryRouter';
Expand Down Expand Up @@ -169,4 +170,17 @@ storiesOf('ais-infinite-hits', module)
</ais-infinite-hits>
</div>
`,
}))
.add('with sessionStorage cache enabled', () => ({
template: `
<ais-infinite-hits :cache="cache">
<div slot="item" slot-scope="{ item, insights }">
custom objectID: {{item.objectID}}
<a href="https://google.com">Go to the detail</a>
</div>
</ais-infinite-hits>
`,
data: () => ({
cache: createInfiniteHitsSessionStorageCache(),
}),
}));