50 so.... today wasn't the best day.
I worked some more on arena_keeper but hit a nasty bug. For some reason it appeared like this simple piece of code was totaly miss behaving.
Code:
js!{
console.log("in buy before? test", @{id.to_string()})
};
let m_chara =self.to_be_chosen.remove(&id);
js!{
console.log("in buy after?", @{id.to_string()})
};
What this should do is print the current id, remove the value with that key in the hashmap and print the id again.
This, seemed to work EXCEPT when I used it to remove the first one in the list. In those cases it would print the correct id as expected but REMOVE the last one.
Now, if you have no idea HOW this could even happen, I am totally in agreement with you. To make matters worse, debugging Rust code that compiles to WASM is a pain to debug. I can't use normal debug tools, there are no source maps to map the WASM code back to the Rust code and all I can print are strings.
For those that are curious about what was the cause of this bug: the piece of code I showed worked perfectly fine. It was my code that renders this list that broke. Rather than simply removing the component corresponding to the removed character Yew reused it by shifting which character belongs to which component up. (so, the component that renders character 1 now renders character 2. The component for character 2 now renders 3, etc, etc) and discards any components that are left.
It does this by calling the "change" function of the affected components, which in my case simply returned true as I totally forgot that yew works this way. This meant that they never got updated to the new character they are supposed to render and thus just showed their old one >_<