Comments (8)
Agree. It would be appropriate for the WIP server_integration example. First, I'm going to first attempt a high-level wrapper for fetch requests: this is a critical missing feature. (Eg like using fetch/axios in ES6, or an async version of Python's Requests.) Asking a user to dive into the raw web_sys fetch/Request API's not feasible. Then would love WebSocket support.
Perhaps once sorted, all this could be placed in a general crate usable by any wasm-bindgen framework.
Related: seanmonstar/reqwest#288
from seed.
Will do. It's on my todo list now. Also, what are your thoughts on implementing a high-level API in Gloo and then pulling it in for use here (just the minimal websocket module)? That would be nice because it would be a bit more universal. If you are good with that, I'll open an issue there, cross link them, and then discuss a bit more with the WASM WG.
from seed.
I think starting with Gloo is the answer, and if you come up with a working soln, but it takes too long for a release or PR merge, we can integrate it into a new Seed version until released in Gloo.
Much like Fetch, I don't see this as being tightly-coupled to a framework.
from seed.
related: #38
from seed.
I've recently built an app with this framework (which is awesome btw) and I used the websockets example to get started with setting up the Websockets integration. I wanted to share a few thoughts on my experience to see what you all think in terms of potential improvements &c.
difficulties
- Using wasm-bindgen types to differentiate between string & binary messages was a bit of a hurdle. I got it working, but I definitely see this as a stumbling block for new users. Could be fairly defeating for some folks I suspect. Eg, need to use ArrayBuffer, passed to a Uint8Array, and then copy it to a vec for access the raw bytes.
- Finding a way to store the callbacks for the Websocket without having to leak all of them (which is obvs not good) could be a stumbling block for folks as well.
a path forward
- We could introduce a higher-level type to store the underlying web-sys Websocket as well as its callbacks. We could just call it
Websocket
. - It could expose a few helper methods, or the like, for being able to handle binary vs text messages.
- We could simply store all of the callbacks in a private vec on the wrapper Websocket type. When it goes out of scope, the callbacks will be dropped as well.
- The callbacks can be simply stored in an
Rc
wrapped inside of an enum to account for function type variance. This is what I did. Worked out pretty well.
Anyway, @David-OConnor you're an absolute champion. Thanks for all of the excellent work you've put into this. This framework is a game-changer, no doubt. I'm happy to help out in any way.
from seed.
Agree - I think the way forward is to add (and document) a high-level WS API. The example's a low-level stopgap that demonstrates it's possible, and shows the web_sys
-level API endpoints we could use when building this API. Complicating factor: I haven't used WS, so am not (yet?) in a position to comment on the details. Want to submit a PR of your path forward? It doesn't have to be complete, documented or finalized: Any API that wraps the web_sys code, and addresses problems you ran into is better than the current approach (ie none).
We can build this iteratively if needed, until reaching an easy-to-use, high-level API. Can start with wrappers that smooth out the web_sys
syntax.
from seed.
@David-OConnor @thedodd I absolutely agree with your direction!
Unfortunately I was quite busy the last month and that won't change in the next couple of weeks/month.
But probably I can test once in a while the current implementation :)
from seed.
@flosse I'm there too re super busy!
from seed.
Related Issues (20)
- error[E0425]: cannot find function `wheel_ev` in this scope HOT 1
- 1. Create a new issue in the Seed repo with the name and copy-paste this checklist into it (also add blockers and additional tasks, if exist).
- Maintenance & Future of Seed HOT 8
- v0.9.1: browser::json::Error is inaccessible
- Deserializing large numbers fail HOT 11
- Websocket example does not work HOT 2
- how to integrate with another wasm ?
- Websocket API changed from 0.8 to 0.9 HOT 5
- DOM node is not attached to ElRef under some conditions HOT 6
- Does not build with wasm-bindgen 0.2.81 HOT 3
- Closures need types HOT 3
- Release v0.9.2 HOT 3
- Seed 0.8 accepting the newest wasm-bindgen HOT 3
- [0.8.x] WebSocket and too early dropped closure HOT 1
- support `beforeinput` events HOT 1
- Seed doesn't compile with `default-features = false` HOT 2
- checkbox not working HOT 2
- Release v0.10.0 HOT 3
- Cannot use subs (subs::UrlChanged) HOT 2
- Error: unresolved import in wasm_bindgen_initialize HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from seed.