@colyseus/schema 2.0.8 → 2.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/index.js +15 -5
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.mjs +14 -5
- package/build/esm/index.mjs.map +1 -1
- package/build/umd/index.js +15 -5
- package/lib/Schema.d.ts +7 -1
- package/lib/Schema.js +14 -5
- package/lib/Schema.js.map +1 -1
- package/lib/codegen/languages/csharp.js +9 -5
- package/lib/codegen/languages/csharp.js.map +1 -1
- package/package.json +2 -2
- package/src/Schema.ts +18 -4
- package/src/codegen/languages/csharp.ts +11 -5
package/build/cjs/index.js
CHANGED
|
@@ -2422,17 +2422,27 @@ var Schema = /** @class */ (function () {
|
|
|
2422
2422
|
Schema.prototype.setDirty = function (property, operation) {
|
|
2423
2423
|
this.$changes.change(property, operation);
|
|
2424
2424
|
};
|
|
2425
|
-
|
|
2425
|
+
/**
|
|
2426
|
+
* Client-side: listen for changes on property.
|
|
2427
|
+
* @param prop the property name
|
|
2428
|
+
* @param callback callback to be triggered on property change
|
|
2429
|
+
* @param immediate trigger immediatelly if property has been already set.
|
|
2430
|
+
*/
|
|
2431
|
+
Schema.prototype.listen = function (prop, callback, immediate) {
|
|
2426
2432
|
var _this = this;
|
|
2433
|
+
if (immediate === void 0) { immediate = true; }
|
|
2427
2434
|
if (!this.$callbacks) {
|
|
2428
2435
|
this.$callbacks = {};
|
|
2429
2436
|
}
|
|
2430
|
-
if (!this.$callbacks[
|
|
2431
|
-
this.$callbacks[
|
|
2437
|
+
if (!this.$callbacks[prop]) {
|
|
2438
|
+
this.$callbacks[prop] = [];
|
|
2439
|
+
}
|
|
2440
|
+
this.$callbacks[prop].push(callback);
|
|
2441
|
+
if (immediate && this[prop] !== undefined) {
|
|
2442
|
+
callback(this[prop], undefined);
|
|
2432
2443
|
}
|
|
2433
|
-
this.$callbacks[attr].push(callback);
|
|
2434
2444
|
// return un-register callback.
|
|
2435
|
-
return function () { return spliceOne(_this.$callbacks[
|
|
2445
|
+
return function () { return spliceOne(_this.$callbacks[prop], _this.$callbacks[prop].indexOf(callback)); };
|
|
2436
2446
|
};
|
|
2437
2447
|
Schema.prototype.decode = function (bytes, it, ref) {
|
|
2438
2448
|
var _a;
|