Skip to content

Latest commit

 

History

History
130 lines (85 loc) · 3.1 KB

CHANGELOG.md

File metadata and controls

130 lines (85 loc) · 3.1 KB

Changelog

2.2.0

No breaking changes in this update.

Added Watch Options

  • [watch]: boolean|WatchOptions

    Now reindex on resource changes can be debounced.

    WatchOptions

    • [delay]: number

      If provided, reindex will be debounced with specified delay.

2.1.0

No breaking changes in this update.

Added new resource index option

  • [watch]: boolean

    Whether needs to reindex if resource changes. This option is useful to avoid reindex overhead when the resource frequently changes.

    Default: true

    Example:

searchPlugin({
  resources: {
    contacts: {
      index: ['address', 'name'],
      getter: state => state.myResources.contacts,
      // Do not reindex automatically if resource changes
      watch: false,
    },
  },
}),

Added more actionTypes

  • reindex

    Mapped action has signature: () => void. To be used when option watch is false. This action will reindex the resource and automatically re-search current search text.

  • registerResource

    Mapped action has signature: (options: IndexOptions) => void. This action will dynamically add resourceName with options provided.

  • unregisterResource

    Mapped action has signature: () => void. This action will unwatch and remove resourceName index.

2.0.0

Option schema changes for defining plugin

In v1.x:

Vuex can use multiple named plugins, where each plugin defines one resourceGetter and one searchApi to be shared by resourceIndexes in the plugin. Thus another plugin must be defined if different searchApi is to be used.

searchPlugin({
  name: 'myIndex',
  resourceIndexes: {
    contacts: ['address', 'name'],
  },
  resourceGetter: (resourceName, state) => state.myResources[resourceName],
  searchApi: new SearchApi();
});

This sturcture may be confusing and redundant, since resource's name itself can already be a unique identifier for an index without plugin's name.

Also, this API makes impossible to support dynamic index registration.

In v2.0:

Similar to v1, custom searchApi can be defined in plugin option. However, now each resource has its own getter and optional searchApi.

searchPlugin({
  resources: {
    contacts: {
      // what fields to index
      index: ['address', 'name'],
      // access the state to be watched by Vuex Search
      getter: state => state.myResources.contacts,
    },
  },
}),

vuex-search v2 also supports dynamic index registration.

Vuex Search can be accessed through store.search or this.$store.search in a Vue instance.

Mappers

In v1.x:

Because plugin can be named, mapActions and mapGetters needs to be composed from composeSearchMappers like so.

import { composeSearchMappers } from 'vuex-search';

// Composing actions and getters from selected plugin name
const { mapSearchGetters, mapSearchActions } = composeSearchMappers('myIndex');

In v2.0:

Plugin name option is removed. Now mappers needn't to be composed.

import {
  mapActions as mapSearchActions,
  mapGetters as mapSearchGetters,
} from 'vuex-search';

1.0.0

Initial release.