Skip to content
This repository was archived by the owner on Feb 20, 2022. It is now read-only.

Commit 97cda1a

Browse files
committed
Indentation and new Event?.Invoke() syntax
1 parent 61312a8 commit 97cda1a

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

unity-project/Assets/Moulin/DDP/local-db/JsonObjectCollection.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,12 @@ public JsonObjectCollection(LocalDB db, string collectionName) {
4848
}
4949

5050
public void Add(string docId, JSONObject fields) {
51-
if (OnAdded != null) {
52-
OnAdded(docId, fields);
53-
}
54-
51+
OnAdded?.Invoke(docId, fields);
5552
documents.Add(docId, fields);
5653
}
5754

5855
public void Change(string docId, JSONObject fields, JSONObject cleared) {
59-
if (OnChanged != null) {
60-
OnChanged(docId, fields, cleared);
61-
}
56+
OnChanged?.Invoke(docId, fields, cleared);
6257

6358
JSONObject document = documents[docId];
6459

@@ -76,10 +71,7 @@ public void Change(string docId, JSONObject fields, JSONObject cleared) {
7671
}
7772

7873
public void Remove(string docId) {
79-
if (OnRemoved != null) {
80-
OnRemoved(docId);
81-
}
82-
74+
OnRemoved?.Invoke(docId);
8375
documents.Remove(docId);
8476
}
8577

unity-project/Assets/Moulin/DDP/local-db/TypedCollection.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ public TypedCollection(LocalDB db, string collectionName,
5656

5757
public void Add(string docId, JSONObject fields) {
5858
DocType document = JSONObjectToDocument(fields);
59-
OnAdded?.Invoke(document);
60-
documents.Add(docId, document);
59+
if (OnAdded != null) {
60+
OnAdded(document);
61+
}
62+
documents.Add(docId, document);
6163
}
6264

6365
public void Change(string docId, JSONObject fields, JSONObject cleared) {
@@ -82,17 +84,21 @@ public void Change(string docId, JSONObject fields, JSONObject cleared) {
8284

8385
DocType newDocument = JSONObjectToDocument(jsonDocument);
8486

85-
OnChanged?.Invoke(oldDocument, newDocument);
87+
if (OnChanged != null) {
88+
OnChanged(oldDocument, newDocument);
89+
}
8690

87-
documents[docId] = newDocument;
91+
documents[docId] = newDocument;
8892
}
8993

9094
public void Remove(string docId) {
9195
DocType document = documents[docId];
9296

93-
OnRemoved?.Invoke(document);
97+
if (OnRemoved != null) {
98+
OnRemoved(document);
99+
}
94100

95-
documents.Remove(docId);
101+
documents.Remove(docId);
96102
}
97103

98104
public void AddBefore(string docId, JSONObject fields, string before) {

0 commit comments

Comments
 (0)