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

expose createLocalStorage #1240

Merged
merged 2 commits into from
Jan 31, 2024
Merged

Conversation

jlvdh
Copy link
Contributor

@jlvdh jlvdh commented Jan 31, 2024

Summary
I'd like to propose to expose the createLocalStorage function. This enables users to initialise the storage object externally from the module.

This is convenient as the onAdd, onRemove and getAll methods are made available and the recent searches can be altered from other places in the codebase.

export const recentSearchesStorage = createLocalStorage({
  key: ["xxxxxx", "navbar"].join(":"),
  limit: 5,
  search: search,
});

const recentSearchesPlugin = createRecentSearchesPlugin({
  storage: recentSearchesStorage,
});

Result

Copy link

codesandbox-ci bot commented Jan 31, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 8e3a2c6:

Sandbox Source
@algolia/autocomplete-example-github-repositories-custom-plugin Configuration
@algolia/autocomplete-example-instantsearch Configuration
@algolia/autocomplete-example-playground Configuration
@algolia/autocomplete-example-preview-panel-in-modal Configuration
@algolia/autocomplete-example-react-renderer Configuration
@algolia/autocomplete-example-starter-algolia Configuration
@algolia/autocomplete-example-starter Configuration
@algolia/autocomplete-example-reshape Configuration
@algolia/autocomplete-example-vue Configuration

@Haroenv Haroenv requested review from a team, dhayab and Haroenv and removed request for a team January 31, 2024 12:30
Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

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

this seems consistent to me as createRecentSearchesPlugin and other underlying layers are also available to be imported. thanks!

Copy link
Member

@dhayab dhayab left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants