ArraySchema<number> issue
See original GitHub issueI had a schema “A” with ArraySchema<number> “items”. Then I push to array “items” values: 1, 2, 3. On Client side A.onChange(value, key) triggers on every update and I got the following values in items:
A.items: [1]
A.items: [undefined, 2]
A.items: [undefined, 2, 3]
You can check it on “02-state-handler” example by adding a few line of code:
Add ArraySchema<number> in Player class:
@type(["number"])
moves = new ArraySchema<number>();
In state class add method:
addItem(id, item) {
this.players[id].moves.push(item);
}
in StateHandlerRoom class call method on every message:
onMessage (client, data) {
console.log("StateHandlerRoom received message from", client.sessionId, ":", data);
this.state.movePlayer(client.sessionId, data);
this.state.addItem(client.sessionId, data.x || data.y );
}
On client-side just add one line in “room.state.players.onChange”:
console.log(player.moves)
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Problems with using basic array schema in flow
Hi all I'm trying to take in some values when into an array when they are created in an MS form. It takes...
Read more >Array schema has no maximum number of items defined
This issue ID and article have been deprecated and will be removed. Description. An array schema does not specify the maximum number of...
Read more >Swagger UI array schema not allowing comma delimit...
Is seems as though because the UI is marking the input of the list of numbers as a number the comma isn't valid....
Read more >Schema - Colyseus & Arena Cloud Documentation
Primitive types are numbers, strings and boolean. ... import { Schema, ArraySchema, type } from "@colyseus/schema"; ... See this issue for a workaround....
Read more >Json with Nested Array Schema
If I used the first object in the JSON, there is no issue. Only when I use the complete JSON array do I...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have sent you my code to your email.
I’m going to close this as it seems to be fixed on the latest versions. Feel free to re-open if you still have problems after upgrading (
rm -R node_modules package-lock.json && npm install
)