跳到主要内容

RxDBPluginReplay

Defined in: packages/rxdb-plugin-replay/src/plugin.ts:26

@aiao/rxdb-plugin-replay 主类:每个连接纪元建一个 ReplayRuntime,纪元释放时停录制并销毁录制库。

Remarks​

使用者面对的是 rxdb.replay(ReplayManager),它在 use() 那一刻挂上,跨纪元不变; 纪元之间成员一律 reject not_installed——「插件没装」与「还没有会话」是两件事,不能都回一个空数组。

Extends​

Implements​

Constructors​

Constructor​

new RxDBPluginReplay(rxdb, options?): RxDBPluginReplay;

Defined in: packages/rxdb-plugin-replay/src/plugin.ts:41

Parameters​

ParameterType
rxdbRxDB
options?RxDBReplayOptions

Returns​

RxDBPluginReplay

Throws​

TypeError / RangeError:选项非法(见 resolveReplayOptions),此时插件不会被登记

Overrides​

RxDBPluginBase.constructor

Properties​

inject​

readonly inject: readonly ["adapter:local"];

Defined in: packages/rxdb-plugin-replay/src/plugin.ts:31

只为与连接纪元对齐:插件从不读写被录的应用库。

Implementation of​

IRxDBPlugin.inject


lifecycle​

readonly lifecycle: "scoped";

Defined in: packages/rxdb-plugin-replay/src/plugin.ts:32

声明本插件已迁移到作用域拆卸。

Remarks​

取值为 'scoped' 时宿主释放完插件作用域就收手,不再调用 IRxDBPlugin.destroy。 双版本插件(既要能装进旧宿主又要能装进新宿主)两样都写:旧宿主不认识本字段、只会走 destroy();新宿主认识,于是只走作用域,两边都不会清理两次。

之所以要显式标记而不是去看 install.length 有没有形参:转译产物、Function.prototype.bind 与压缩器都会改写形参个数,把它当契约会误判。

Implementation of​

IRxDBPlugin.lifecycle


manager​

readonly manager: ReplayManager;

Defined in: packages/rxdb-plugin-replay/src/plugin.ts:36

rxdb.replay 门面。


name​

readonly name: "replay" = 'replay';

Defined in: packages/rxdb-plugin-replay/src/plugin.ts:29

插件名,用于日志与宿主侧的错误归因

Implementation of​

IRxDBPlugin.name


options​

readonly options: ResolvedReplayOptions;

Defined in: packages/rxdb-plugin-replay/src/plugin.ts:34

补齐默认值、校验过的选项。


rxdb​

protected readonly rxdb: RxDB;

Defined in: packages/rxdb/dist/rxdb-plugin.d.ts:136

Inherited from​

RxDBPluginBase.rxdb

Methods​

install()​

install(scope): void;

Defined in: packages/rxdb-plugin-replay/src/plugin.ts:48

安装插件。

Parameters​

ParameterTypeDescription
scopeLifecycleScope本次连接纪元的插件激活作用域;一次 acquire() 只包一步可能抛错的获取

Returns​

void

Remarks​

抛错(含 Promise reject)视为安装失败:宿主会先把已经登记进 scope 的部分 逆序释放掉,再把原错误传播给 connect()。回滚期间的清理错误只记日志,不会盖掉安装错误。

实现方不写形参不破坏契约——install() 与 install(scope) 同样满足本接口。

Implementation of​

IRxDBPlugin.install