-
-
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 #536 from streamich/cnt-extension
JSON CRDT `cnt` extension refactor
- Loading branch information
Showing
4 changed files
with
51 additions
and
20 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* tslint:disable no-console */ | ||
|
||
/** | ||
* Run this demo with: | ||
* | ||
* npx nodemon -q -x ts-node src/json-crdt-extensions/cnt/__demos__/usage.ts | ||
*/ | ||
|
||
import {Model, s} from '../../../json-crdt'; | ||
import {CntExt} from '..'; | ||
|
||
console.clear(); | ||
|
||
const model = Model.withLogicalClock(1234); | ||
|
||
model.ext.register(CntExt); | ||
|
||
model.api.root({ | ||
cnt: CntExt.new(42), | ||
}); | ||
|
||
console.log(''); | ||
console.log('Initial value:'); | ||
console.log(model + ''); | ||
|
||
const api = model.api.in(['cnt']).asExt(CntExt); | ||
|
||
api.inc(10); | ||
|
||
console.log(''); | ||
console.log('After update:'); | ||
console.log(model + ''); |
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
export const enum ExtensionId { | ||
mval = 0, | ||
gcnt = 1, | ||
pncnt = 2, | ||
peritext = 3, | ||
quill = 4, | ||
cnt = 1, | ||
peritext = 2, | ||
quill = 3, | ||
} |