Last active
February 5, 2018 22:41
-
-
Save joshgarnett/a69bf60757f7b627f1e75d29246e3a0d to your computer and use it in GitHub Desktop.
Proposal for deltas of messages within a RepeatedField
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
var foo = new SimpleNestedMessage(); | |
list.Add(foo); | |
// Generates: new EventData { Action = AddList, EventContent = foo.toByteString() , Path = [1, 0]} // 0 is the index of foo object | |
// Sets _root and _path in the foo instance | |
// if _root already exists throw exception, can't add message to two parents at once | |
foo.a = 10; | |
// Generates: new EventData { Action = Set, EventContent = 10 , Path = [1, 0, 1]} | |
foo.b = "hello"; | |
// Generates: new EventData { Action = Set, EventContent = "hello" , Path = [1, 0, 2]} | |
var bar = new SimpleNestedMessage(); | |
list.Insert(bar); | |
// Generates: new EventData { Action = InsertList, Field = 0, EventContent = bar.toByteString() , Path = [1, 0]} // 0 is the index of bar object | |
// Updates path on any objects that appear after bar, in this case foo, becomes index 1 | |
// Sets _root and _path in the bar instance | |
// if _root already exists throw exception, can't add message to two parents at once | |
foo.a = 11; | |
// Generates: new EventData { Action = Set, EventContent = 11 , Path = [1, 1, 1]} // 1 is the index of foo object now | |
list.RemoveAt(0); | |
// Generates: new EventData { Action = RemoveAtList, Path = [1, 0]} | |
// Updates path on any objects that appear after bar, in this case foo, becomes index 1 | |
// clears _root & _path on the bar object | |
var baz = new SimpleNestedMessage(); | |
list[0] = baz; | |
// Generates: new EventData { Action = ReplaceList, EventContent = baz.toByteString() , Path = [1, 0]} | |
// clears _root & _path on the foo object | |
// Sets _root and _path in the baz instance | |
// if _root already exists throw exception, can't add message to two parents at once |
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
message SimpleNestedMessage { | |
int64 a = 1; | |
string b = 2; | |
} | |
message SimpleList { | |
repeated SimpleNestedMessage = 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment