You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(events): implement value change tracking and difference tracking
- Add value change event propagation through selections
- Implement Difference and Patch for tracking changes
- Add tests for difference tracking and value changes
- Update documentation with event system examples
Copy file name to clipboardExpand all lines: README.md
+41-43Lines changed: 41 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,6 +69,9 @@ Core Functionality:
69
69
-[x] Universal associative graph data structure
70
70
-[x] Uniform interface for all data types
71
71
-[x] Reactive event system
72
+
-[x] Value change tracking
73
+
-[x] Selection-based event propagation
74
+
-[x] Difference tracking for collections
72
75
-[x] Complex querying with logical operators
73
76
-[ ] Event generation and applying
74
77
-[ ] Export Selection to JSON and import as Selection
@@ -154,7 +157,7 @@ AI Integration:
154
157
155
158
The **Deep** class is the core of the system - it represents a universal agent capable of performing operations on any type of data. Each instance of Deep is an active agent that can interact with any other Deep instance or data type through a rich set of methods:
156
159
157
-
### Data Operations
160
+
####Data Operations
158
161
159
162
All methods work uniformly across different data types, treating single items as collections of one element where the item serves as both key and value. This approach allows for consistent data manipulation regardless of whether you're working with a single item or a collection.
160
163
@@ -179,46 +182,49 @@ All methods work uniformly across different data types, treating single items as
-`valueOf()` → any - Returns primitive value if possible
181
184
182
-
###Operations
185
+
#### Selection
183
186
184
-
#### Select
187
+
Selections in Deep are powerful reactive queries that not only retrieve data but also track changes in real-time. They provide a comprehensive event system that propagates changes throughout the semantic graph:
185
188
186
-
<details>
187
-
<summary>Examples</summary>
189
+
-**Value Change Events**: Track modifications to node values within the selection
190
+
-**Selection Events**: Monitor changes in selection contents (additions/removals)
191
+
-**Difference Tracking**: Track detailed changes in selections over time
192
+
-**Event Propagation**: Events automatically propagate through related selections
188
193
194
+
Example of tracking value changes in a selection:
189
195
```typescript
190
-
const A =deep.new();
191
-
const B =deep.new();
192
-
const C =deep.new();
193
-
const X =deep.new();
196
+
const Type1 =deep.new();
197
+
const instance =Type1.new();
198
+
199
+
// Create and monitor a selection
200
+
const selection =deep.select({ type: Type1 });
201
+
selection.on((event) => {
202
+
if (event.name==='change'&&event.field==='value') {
203
+
console.log('Value changed:', event);
204
+
}
205
+
});
194
206
195
-
const a =A.new();
196
-
const b1 =B.new();
197
-
b1.from=a;
198
-
const c =C.new();
199
-
c.from=a;
200
-
201
-
const x =X.new();
202
-
const b2 =B.new();
203
-
b2.from=x;
204
-
205
-
// Search by specific relations
206
-
deep.select({ type: C }).to; // Deep<Set<[c]>>
207
-
208
-
// Search for links that referenced from B
209
-
deep.select({
210
-
out: { type: B }
211
-
}).to; // Deep<Set<[a,x]>>
212
-
213
-
// Get only those links from which both B and C instances originate at least one
214
-
deep.select({
215
-
and: [
216
-
{ out: { type: B } },
217
-
{ out: { type: C } },
218
-
]
219
-
}).to; // Deep<Set<[a]>>
207
+
// Changes to instance will trigger selection events
0 commit comments