wasm-bindgen/examples/webxr
Liam Murphy 823f57698c
Deprecate JsValue::from_serde and JsValue::into_serde (#3031)
* Deprecate `JsValue::from_serde` and `JsValue::into_serde`

I've listed `serde-wasm-bindgen` as the replacement, and changed the section of the guide that talks about Serde to talk about `serde-wasm-bindgen` instead of the deprecated methods.

I didn't remove it entirely because I can imagine someone remembering it and trying to look it back up, only to find that it no longer exists, which would quite frustrating. I also added a footnote about the deprecated methods in case someone remembers the old way and wants to know what happened.

There were several examples using `from_serde`/`into_serde`, which I updated to use `serde-wasm-bindgen` or not use `serde` altogether.

The `fetch` example was a bit weird, in that it took a JS value, parsed it into a Rust value, only to serialize it back into a JS value. I removed that entirely in favour of just passing the original JS value directly. I suppose it behaves slightly differently in that it loses the extra validation, but a panic isn't all that much better than a JS runtime error.

* fmt

* Mention JSON as an alternative to `serde-wasm-bindgen`

* Use `gloo-utils` instead of raw `JSON`

I was considering leaving the examples using `JSON` directly and mentioning `gloo-utils` as an aside, but that has the major footgun that `JSON.stringify(undefined) === undefined`, causing a panic when deserializing `undefined` since the return type of `JSON::stringify` isn't optional. `gloo-utils` works around this, so I recommended it instead.

* Mention `gloo-utils` in API docs

* Rephrase section about deprecated methods
2022-08-29 23:17:27 -05:00
..
src Deprecate JsValue::from_serde and JsValue::into_serde (#3031) 2022-08-29 23:17:27 -05:00
Cargo.toml Deprecate JsValue::from_serde and JsValue::into_serde (#3031) 2022-08-29 23:17:27 -05:00
index.html Fix canvas is not a self closing tag. (#2408) 2021-01-04 09:31:01 -06:00
index.js Webxrdevice (#2000) 2020-03-17 09:14:05 -05:00
package.json Upgrade the webpack-based examples' npm dependencies (move to webpack 5) (#2651) 2021-08-10 09:43:42 -05:00
README.md Webxrdevice (#2000) 2020-03-17 09:14:05 -05:00
webpack.config.js Upgrade the webpack-based examples' npm dependencies (move to webpack 5) (#2651) 2021-08-10 09:43:42 -05:00
webxr.js Upgrade the webpack-based examples' npm dependencies (move to webpack 5) (#2651) 2021-08-10 09:43:42 -05:00

WebXR Example

View documentation for this example online or View compiled example online

You can build the example locally with:

# Note: Requires unstable flag whilst WebXR in development
$ RUSTFLAGS=--cfg=web_sys_unstable_apis npm run serve

and then visiting http://localhost:8080 in a browser should run the example!