File tree 2 files changed +9
-7
lines changed
2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,9 @@ export class JsonPatch<N extends JsonNode = JsonNode<any>> {
15
15
16
16
public apply ( ops : Operation [ ] ) : this {
17
17
const length = ops . length ;
18
- for ( let i = 0 ; i < length ; i ++ ) this . applyOp ( ops [ i ] ) ;
18
+ this . model . api . transaction ( ( ) => {
19
+ for ( let i = 0 ; i < length ; i ++ ) this . applyOp ( ops [ i ] ) ;
20
+ } ) ;
19
21
return this ;
20
22
}
21
23
Original file line number Diff line number Diff line change @@ -9,23 +9,23 @@ import type {JsonNode, JsonNodeView} from '../nodes';
9
9
export class JsonPatchStore < N extends JsonNode = JsonNode < any > > implements SyncStore < Readonly < JsonNodeView < N > > > {
10
10
public readonly node : N ;
11
11
public readonly api : JsonNodeApi < N > ;
12
- protected _patcher : JsonPatch < N > ;
13
- protected _pfx : string ;
12
+ public readonly patcher : JsonPatch < N > ;
13
+ public readonly pfx : string ;
14
14
15
15
constructor (
16
16
protected readonly model : Model < N > ,
17
- protected readonly path : Path = [ ] ,
17
+ public readonly path : Path = [ ] ,
18
18
) {
19
- this . _pfx = path . length ? path . join ( ) : '' ;
19
+ this . pfx = path . length ? path . join ( ) : '' ;
20
20
const api = model . api ;
21
21
this . node = api . find ( path ) as N ;
22
22
this . api = api . wrap ( this . node ) as unknown as JsonNodeApi < N > ;
23
- this . _patcher = new JsonPatch ( model , path ) ;
23
+ this . patcher = new JsonPatch ( model , path ) ;
24
24
}
25
25
26
26
public readonly update = ( change : Operation | Operation [ ] ) : void => {
27
27
const ops = Array . isArray ( change ) ? change : [ change ] ;
28
- this . _patcher . apply ( ops ) ;
28
+ this . patcher . apply ( ops ) ;
29
29
} ;
30
30
31
31
// ---------------------------------------------------------------- SyncStore
You can’t perform that action at this time.
0 commit comments