UNPKG

@vuex-orm/plugin-search

Version:

Vuex ORM plugin for adding fuzzy search feature through model entities.

37 lines 1.13 kB
import { __assign } from "tslib"; import DefaultOptions from './config/DefaultOptions'; import QueryMixin from './mixins/Query'; var VuexORMSearch = /** @class */ (function () { /** * Create a new Vuex ORM Search instance. */ function VuexORMSearch(components, options) { this.query = components.Query; this.options = __assign(__assign({}, DefaultOptions), options); } /** * Plug in features. */ VuexORMSearch.prototype.plugin = function () { this.mixQuery(); this.registerQueryHook(); }; /** * Apply query mixin. */ VuexORMSearch.prototype.mixQuery = function () { QueryMixin(this.query, this.options); }; /** * Register global `afterWhere` hook to execute search filtering during the * select process. */ VuexORMSearch.prototype.registerQueryHook = function () { this.query.on('afterWhere', function (collection) { return this.filterSearch(collection); }); }; return VuexORMSearch; }()); export default VuexORMSearch; //# sourceMappingURL=VuexORMSearch.js.map