RxDBPluginQueryCache
Defined in: rxdb-plugin-querycache/src/plugin.ts:23
QueryCache 读引擎插件。
Remarks
不声明 inject:注册工厂是纯动作,不需要任何适配器就绪。声明了依赖反而会让安装
排到 connect() 的启动护栏之后 —— 那道护栏专门检查「声明了 QueryCache 却没装引擎」,
装得太晚就变成误报。
Extends
Implements
Constructors
Constructor
new RxDBPluginQueryCache(rxdb): RxDBPluginQueryCache;
Defined in: rxdb/dist/rxdb-plugin.d.ts:137
Parameters
| Parameter | Type |
|---|---|
rxdb | RxDB |
Returns
RxDBPluginQueryCache
Inherited from
Properties
lifecycle
readonly lifecycle: "scoped";
Defined in: rxdb-plugin-querycache/src/plugin.ts:24
声明本插件已迁移到作用域拆卸。
Remarks
取值为 'scoped' 时宿主释放完插件作用域就收手,不再调用 IRxDBPlugin.destroy。
双版本插件(既要能装进旧宿主又要能装进新宿主)两样都写:旧宿主不认识本字段、只会走
destroy();新宿主认识,于是只走作用域,两边都不会清理两次。
之所以要显式标记而不是去看 install.length 有没有形参:转译产物、Function.prototype.bind
与压缩器都会改写形参个数,把它当契约会误判。
Implementation of
name
name: Uncapitalize<string> = 'queryCache';
Defined in: rxdb-plugin-querycache/src/plugin.ts:25
插件名,用于日志与宿主侧的错误归因
Implementation of
rxdb
protected readonly rxdb: RxDB;
Defined in: rxdb/dist/rxdb-plugin.d.ts:136
Inherited from
Methods
install()
install(scope): void;
Defined in: rxdb-plugin-querycache/src/plugin.ts:27
安装插件。
Parameters
| Parameter | Type | Description |
|---|---|---|
scope | LifecycleScope | 本次连接纪元的插件激活作用域;一次 acquire() 只包一步可能抛错的获取 |
Returns
void
Remarks
抛错(含 Promise reject)视为安装失败:宿主会先把已经登记进 scope 的部分
逆序释放掉,再把原错误传播给 connect()。回滚期间的清理错误只记日志,不会盖掉安装错误。
实现方不写形参不破坏契约——install() 与 install(scope) 同样满足本接口。