Skip to content

Commit

Permalink
deprecate 'changes' list on .onChange() callback. (please use .listen…
Browse files Browse the repository at this point in the history
…() instead.)
  • Loading branch information
endel committed Aug 24, 2023
1 parent 4af2a94 commit 7a99c3d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@colyseus/schema",
"version": "2.0.13",
"version": "2.0.14",
"description": "Binary state serializer with delta encoding for games",
"bin": {
"schema-codegen": "./bin/schema-codegen"
Expand Down
4 changes: 2 additions & 2 deletions src/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export abstract class Schema {
// protected $listeners: { [field: string]: Array<(value: any, previousValue: any) => void> };
protected $callbacks: { [op: number]: Array<Function> };

public onChange(callback: (changes: DataChange[]) => void): () => void {
public onChange(callback: () => void): () => void {
return addCallback((this.$callbacks || (this.$callbacks = [])), OPERATION.REPLACE, callback);
}
public onRemove(callback: () => void): () => void {
Expand Down Expand Up @@ -976,7 +976,7 @@ export abstract class Schema {
try {
// trigger onChange
($callbacks as Schema['$callbacks'])?.[OPERATION.REPLACE]?.forEach(callback =>
callback(changes));
callback());

} catch (e) {
Schema.onError(e);
Expand Down

0 comments on commit 7a99c3d

Please sign in to comment.