Skip to content

Commit

Permalink
NFC: inline insert/delete update handling
Browse files Browse the repository at this point in the history
  • Loading branch information
RReverser committed May 10, 2024
1 parent 07633ad commit ea22959
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 221 deletions.
7 changes: 0 additions & 7 deletions examples/quickstart/client/module_bindings/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,9 @@ public static bool ComparePrimaryKey(SpacetimeDB.SATS.AlgebraicType t, Spacetime

public delegate void InsertEventHandler(Message insertedValue, SpacetimeDB.Types.ReducerEvent dbEvent);
public delegate void DeleteEventHandler(Message deletedValue, SpacetimeDB.Types.ReducerEvent dbEvent);
public delegate void RowUpdateEventHandler(SpacetimeDBClient.TableOp op, Message oldValue, Message newValue, SpacetimeDB.Types.ReducerEvent dbEvent);
public static event InsertEventHandler OnInsert;
public static event DeleteEventHandler OnBeforeDelete;
public static event DeleteEventHandler OnDelete;
public static event RowUpdateEventHandler OnRowUpdate;

public static void OnInsertEvent(object newValue, ClientApi.Event dbEvent)
{
Expand All @@ -129,10 +127,5 @@ public static void OnDeleteEvent(object oldValue, ClientApi.Event dbEvent)
{
OnDelete?.Invoke((Message)oldValue,(ReducerEvent)dbEvent?.FunctionCall.CallInfo);
}

public static void OnRowUpdateEvent(SpacetimeDBClient.TableOp op, object oldValue, object newValue, ClientApi.Event dbEvent)
{
OnRowUpdate?.Invoke(op, (Message)oldValue,(Message)newValue,(ReducerEvent)dbEvent?.FunctionCall.CallInfo);
}
}
}
7 changes: 0 additions & 7 deletions examples/quickstart/client/module_bindings/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,10 @@ public static SpacetimeDB.SATS.AlgebraicType GetPrimaryKeyType(SpacetimeDB.SATS.
public delegate void InsertEventHandler(User insertedValue, SpacetimeDB.Types.ReducerEvent dbEvent);
public delegate void UpdateEventHandler(User oldValue, User newValue, SpacetimeDB.Types.ReducerEvent dbEvent);
public delegate void DeleteEventHandler(User deletedValue, SpacetimeDB.Types.ReducerEvent dbEvent);
public delegate void RowUpdateEventHandler(SpacetimeDBClient.TableOp op, User oldValue, User newValue, SpacetimeDB.Types.ReducerEvent dbEvent);
public static event InsertEventHandler OnInsert;
public static event UpdateEventHandler OnUpdate;
public static event DeleteEventHandler OnBeforeDelete;
public static event DeleteEventHandler OnDelete;
public static event RowUpdateEventHandler OnRowUpdate;

public static void OnInsertEvent(object newValue, ClientApi.Event dbEvent)
{
Expand All @@ -152,10 +150,5 @@ public static void OnDeleteEvent(object oldValue, ClientApi.Event dbEvent)
{
OnDelete?.Invoke((User)oldValue,(ReducerEvent)dbEvent?.FunctionCall.CallInfo);
}

public static void OnRowUpdateEvent(SpacetimeDBClient.TableOp op, object oldValue, object newValue, ClientApi.Event dbEvent)
{
OnRowUpdate?.Invoke(op, (User)oldValue,(User)newValue,(ReducerEvent)dbEvent?.FunctionCall.CallInfo);
}
}
}
Loading

0 comments on commit ea22959

Please sign in to comment.