-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #530 from streamich/extensions-2
Extensions 2
- Loading branch information
Showing
9 changed files
with
58 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export const enum ExtensionId { | ||
MvValue = 0, | ||
mval = 0, | ||
Peritext = 1, | ||
QuillDelta = 2, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* tslint:disable no-console */ | ||
|
||
/** | ||
* Run this demo with: | ||
* | ||
* npx nodemon -q -x ts-node src/json-crdt-extensions/mval/__demos__/usage.ts | ||
*/ | ||
|
||
import {Model, s} from '../../../json-crdt'; | ||
import {ValueMvExt} from '..'; | ||
|
||
console.clear(); | ||
|
||
const model = Model.withLogicalClock(1234); | ||
|
||
model.ext.register(ValueMvExt); | ||
|
||
model.api.root({ | ||
obj: { | ||
mv: ValueMvExt.new(s.con(1)), | ||
}, | ||
}); | ||
|
||
console.log(''); | ||
console.log('Initial value:'); | ||
console.log(model + ''); | ||
|
||
const api = model.api.in(['obj', 'mv']).asExt(ValueMvExt); | ||
|
||
api.set(s.con(5)); | ||
|
||
console.log(''); | ||
console.log('After update:'); | ||
console.log(model + ''); | ||
|
||
const model2 = model.fork(); | ||
|
||
const api2 = model2.api.in(['obj', 'mv']).asExt(ValueMvExt); | ||
|
||
api.set(s.con(10)); | ||
api2.set(s.con(20)); | ||
model.applyPatch(model2.api.flush()); | ||
|
||
console.log(''); | ||
console.log('After two users update concurrently:'); | ||
console.log(model + ''); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters