From 7a99c3de5b6e4602ddf816d3dafe339d4f889238 Mon Sep 17 00:00:00 2001 From: Endel Dreyer Date: Thu, 24 Aug 2023 19:03:07 -0300 Subject: [PATCH] deprecate 'changes' list on .onChange() callback. (please use .listen() instead.) --- package.json | 2 +- src/Schema.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 5bbf5441..ac08c59b 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/Schema.ts b/src/Schema.ts index 25c6bd5b..6505d3bd 100644 --- a/src/Schema.ts +++ b/src/Schema.ts @@ -140,7 +140,7 @@ export abstract class Schema { // protected $listeners: { [field: string]: Array<(value: any, previousValue: any) => void> }; protected $callbacks: { [op: number]: Array }; - 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 { @@ -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);