screeps-game-api
screeps-game-api copied to clipboard
feat: use gloo_utils for parsing
This PR does two things:
- Use
JSValue::.into_serde()from gloo utils. I was having problems with theserde_wasm_bindgen::from_value. More specifically, I kept seeing:caught exception: SyntaxError: Unexpected token { - By adding
Serializeto the Path enum, we can easily callmove_by_pathusing the serialized/stringified version of the Path.
e.g.
creep.move_by_path(&JsValue::from_str(&path.to_string()))
Close it, merge it, w/e you wish. I couldn't get serde_wasm_bindgen working locally so I just wanted to leave this here if anyone else encountered a similar issue.
Tried to reproduce this, and wasn't able to - can you provide any more info about how you're calling this that it's not working? I'm doing a simple test of find_path_to from one Position to another with a default callback and it's deserializing the returned result happily via serde-wasm-bindgen.
Hmm interesting. I haven't played screeps in a hot second, but I can pull up my code and give it another whirl with the main branch this weekend to see if the issue still persists.