LWWConflictResolver
Defined in: packages/rxdb/src/version/LWWConflictResolver.ts:21
Last-Write-Wins 冲突解决器
基于 createdAt 时间戳,更晚的变更胜出 这是默认的冲突解决策略
Example
const resolver = new LWWConflictResolver();
const resolution = await resolver.resolve(conflict);
if (resolution.type === 'KEEP_LOCAL') {
// 使用本地变更
} else {
// 使用远程变更
}
Implements
Constructors
Constructor
new LWWConflictResolver(): LWWConflictResolver;
Returns
LWWConflictResolver
Methods
resolve()
resolve(conflict): Promise<ConflictResolution>;
Defined in: packages/rxdb/src/version/LWWConflictResolver.ts:31
解决单个冲突
比较本地和远程变更的 createdAt 时间戳,更晚的胜出 当时间戳相等时,本地优先
Parameters
| Parameter | Type | Description |
|---|---|---|
conflict | Conflict | 冲突信息 |
Returns
Promise<ConflictResolution>
冲突解决结果
Implementation of
resolveAll()
resolveAll(conflicts): Promise<ConflictResolution[]>;
Defined in: packages/rxdb/src/version/LWWConflictResolver.ts:46
批量解决冲突
逐个调用 resolve() 方法
Parameters
| Parameter | Type | Description |
|---|---|---|
conflicts | Conflict[] | 冲突列表 |
Returns
Promise<ConflictResolution[]>
解决结果列表