@aiao/rxdb-plugin-search-vue
@aiao/rxdb-plugin-search-vue
@aiao/rxdb-plugin-search 的 Vue 集成层。提供 useSearch() composable,将搜索插件的 SearchHandle 适配为 Vue ref / reactive 消费接口。
安装
pnpm add @aiao/rxdb @aiao/rxdb-plugin-search @aiao/rxdb-plugin-search-vue vue rxjs
用法
<script lang="ts" setup>
import { useSearch } from '@aiao/rxdb-plugin-search-vue';
</script>
useSearch:返回响应式的SearchState(结果、加载态与错误)- 类型:
UseSearchReturn、SearchSourceLike
挂载组件之前先装插件并连接:database.use(rxDBPluginSearch, …) → await database.connect('sqlite-wasm')。
插件声明 inject: ['adapter:local'],宿主在本地适配器就绪后才安装它,因此 await connect() 返回时
FTS 已经装好;database.searchPlugin.ready 是「装上没有」的显式确认——安装成功 resolve,失败 reject
原始错误,纪元被释放(断连 / 回滚)后 reject destroyed。它一个连接纪元一格,重连之后要重新读一次。
响应式入参与重建契约(三端一致)
source 与 options 都接受 MaybeRefOrGetter(值 / Ref / ComputedRef / getter)。
解析值变化时旧 SearchHandle 被销毁、新 handle 以用户当前 query 播种:
initialQuery只在首次创建时作种子,此后不再参与重建判据, 因此传initialQuery: query不会导致每次击键重建 handle;options按语义(collections/debounce/pageSize/snippetLength)而非引用比较, 每次重算新建的字面量不触发重建;- 重建后
loadMore/clear/retry一律路由到最新 handle,旧 handle 的晚到 emission 不再写入输出。
判据由 core 的 searchOptionsEqual 三端共用,重建时机不会因框架而异。
三框架同功能对称:Angular 用 injectSearch(@aiao/rxdb-plugin-search-angular),React 用 useSearch(@aiao/rxdb-plugin-search-react)。
文档
- 仓库主页:https://github.com/aiao-io/rxdb
- 框架集成与搜索指南见项目文档站
License
Related Packages
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 0.0.28 | ^3.5.43 | MIT | |
| 0.0.26 | ^3.5.42 | MIT | |
| 0.0.25 | ^3.5.41 | MIT | |
| 0.0.24 | >=3.5.0 | MIT | |
| 0.0.23 | >=3.5.0 | ||
| 0.0.22 | >=3.5.0 | ||
| 0.0.21 | >=3.5.0 | ||
| 0.0.20 | >=3.5.0 |