Skip to content

Commit 0f737a0

Browse files
committed
Added DualParseLiveQueryEventArgs
1 parent 40044a2 commit 0f737a0

File tree

4 files changed

+37
-19
lines changed

4 files changed

+37
-19
lines changed

Parse/Abstractions/Platform/LiveQueries/IParseLiveQuerySubscription.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ public interface IParseLiveQuerySubscription
2424
/// This event is triggered when an object that did not previously match the query (and was thus not part of the subscription)
2525
/// starts matching the query, typically due to an update.
2626
/// </summary>
27-
public event EventHandler<ParseLiveQueryEventArgs> Enter;
27+
public event EventHandler<DualParseLiveQueryEventArgs> Enter;
2828

2929
/// <summary>
3030
/// Represents the Update event for a live query subscription.
3131
/// This event is triggered when an existing object matching the subscription's query is updated.
3232
/// </summary>
33-
public event EventHandler<ParseLiveQueryEventArgs> Update;
33+
public event EventHandler<DualParseLiveQueryEventArgs> Update;
3434

3535
/// <summary>
3636
/// Represents the Leave event for a live query subscription.
3737
/// This event is triggered when an object that previously matched the subscription's query
3838
/// no longer matches the criteria and is removed.
3939
/// </summary>
40-
public event EventHandler<ParseLiveQueryEventArgs> Leave;
40+
public event EventHandler<DualParseLiveQueryEventArgs> Leave;
4141

4242
/// <summary>
4343
/// Represents the Delete event for a live query subscription.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
namespace Parse.Platform.LiveQueries;
2+
3+
/// <summary>
4+
/// Provides event arguments for events triggered by Parse's Live Query service.
5+
/// This class encapsulates details about a particular event, such as the operation type,
6+
/// client ID, request ID, and the associated Parse object data.
7+
/// </summary>
8+
public class DualParseLiveQueryEventArgs : ParseLiveQueryEventArgs
9+
{
10+
/// <summary>
11+
/// Represents the event arguments provided to Live Query event handlers in the Parse platform.
12+
/// This class provides information about the current and original state of the Parse object
13+
/// involved in the Live Query operation.
14+
/// </summary>
15+
internal DualParseLiveQueryEventArgs(ParseObject current, ParseObject original) : base(current)
16+
{
17+
Original = original;
18+
}
19+
20+
/// <summary>
21+
/// Gets the state of the Parse object before the live query event was triggered.
22+
/// This property represents the original data of the Parse object prior to any updates,
23+
/// providing a snapshot of its previous state for comparison purposes during events
24+
/// such as updates or deletes.
25+
/// </summary>
26+
public ParseObject Original { get; private set; }
27+
}

Parse/Platform/LiveQueries/ParseLiveQueryEventArgs.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ public class ParseLiveQueryEventArgs : EventArgs
1414
/// This class provides information about the current and original state of the Parse object
1515
/// involved in the Live Query operation.
1616
/// </summary>
17-
internal ParseLiveQueryEventArgs(ParseObject current, ParseObject original = null)
17+
internal ParseLiveQueryEventArgs(ParseObject current)
1818
{
1919
Object = current;
20-
Original = original;
2120
}
2221

2322
/// <summary>
@@ -27,12 +26,4 @@ internal ParseLiveQueryEventArgs(ParseObject current, ParseObject original = nul
2726
/// an update or creation.
2827
/// </summary>
2928
public ParseObject Object { get; private set; }
30-
31-
/// <summary>
32-
/// Gets the state of the Parse object before the live query event was triggered.
33-
/// This property represents the original data of the Parse object prior to any updates,
34-
/// providing a snapshot of its previous state for comparison purposes during events
35-
/// such as updates or deletes.
36-
/// </summary>
37-
public ParseObject Original { get; private set; }
3829
}

Parse/Platform/LiveQueries/ParseLiveQuerySubscription.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ public class ParseLiveQuerySubscription<T> : IParseLiveQuerySubscription where T
2929
/// This event is triggered when an object that did not previously match the query (and was thus not part of the subscription)
3030
/// starts matching the query, typically due to an update.
3131
/// </summary>
32-
public event EventHandler<ParseLiveQueryEventArgs> Enter;
32+
public event EventHandler<DualParseLiveQueryEventArgs> Enter;
3333

3434
/// <summary>
3535
/// Represents the Update event for a live query subscription.
3636
/// This event is triggered when an existing object matching the subscription's query is updated.
3737
/// </summary>
38-
public event EventHandler<ParseLiveQueryEventArgs> Update;
38+
public event EventHandler<DualParseLiveQueryEventArgs> Update;
3939

4040
/// <summary>
4141
/// Represents the Leave event for a live query subscription.
4242
/// This event is triggered when an object that previously matched the subscription's query
4343
/// no longer matches the criteria and is removed.
4444
/// </summary>
45-
public event EventHandler<ParseLiveQueryEventArgs> Leave;
45+
public event EventHandler<DualParseLiveQueryEventArgs> Leave;
4646

4747
/// <summary>
4848
/// Represents the Delete event for a live query subscription.
@@ -112,7 +112,7 @@ public void OnCreate(IObjectState objectState)
112112
/// <param name="originalState">The original state of the object before entering the query result set.</param>
113113
public void OnEnter(IObjectState objectState, IObjectState originalState)
114114
{
115-
Enter?.Invoke(this, new ParseLiveQueryEventArgs(
115+
Enter?.Invoke(this, new DualParseLiveQueryEventArgs(
116116
Services.GenerateObjectFromState<T>(objectState, ClassName),
117117
Services.GenerateObjectFromState<T>(originalState, ClassName)));
118118
}
@@ -125,7 +125,7 @@ public void OnEnter(IObjectState objectState, IObjectState originalState)
125125
/// <param name="originalState">The original state of the object before the update.</param>
126126
public void OnUpdate(IObjectState objectState, IObjectState originalState)
127127
{
128-
Update?.Invoke(this, new ParseLiveQueryEventArgs(
128+
Update?.Invoke(this, new DualParseLiveQueryEventArgs(
129129
Services.GenerateObjectFromState<T>(objectState, ClassName),
130130
Services.GenerateObjectFromState<T>(originalState, ClassName)));
131131
}
@@ -139,7 +139,7 @@ public void OnUpdate(IObjectState objectState, IObjectState originalState)
139139
/// <param name="originalState">The original state of the object before it left the result set.</param>
140140
public void OnLeave(IObjectState objectState, IObjectState originalState)
141141
{
142-
Leave?.Invoke(this, new ParseLiveQueryEventArgs(
142+
Leave?.Invoke(this, new DualParseLiveQueryEventArgs(
143143
Services.GenerateObjectFromState<T>(objectState, ClassName),
144144
Services.GenerateObjectFromState<T>(originalState, ClassName)));
145145
}

0 commit comments

Comments
 (0)