update(simperium): add missing optional parameters to event listener (#45814)

When creating the original types there was an oversight in the event
types for the `Channel` and its `update` event. In some cases the
event fires only with the first two parameters: the entity id and
data. In the normative case however there are additional parameters
available indicating meta information about the update. Those
optional paramters have been added here.

Although it looks like all three of the last parameters are optional
it's actually the case that either you get only the first two or
all five. It would not occur that you only get three or four of them
but I wasn't sure how to type this beyond function overloads and I
believe that it's not the best idea to use function overloads for
optional parameters.
This commit is contained in:
Dennis Snell 2020-07-06 15:36:38 -06:00 committed by GitHub
parent b9f4e2353b
commit 6c2bcffe68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -179,7 +179,13 @@ interface ChannelEvent<T> extends SimperiumEvent {
indexingStateChange: (isIndexing: boolean) => void;
ready: () => void;
send: (message: string) => void;
update: (entityId: EntityId, updatedEntity: T) => void;
update: (
entityId: EntityId,
updatedEntity: T,
originalEntity?: T,
patch?: JSONDiff<T>,
isIndexing?: boolean,
) => void;
version: (entityId: EntityId, version: number, entity: T) => void;
}