Replies: 3 comments 9 replies
-
Although I feel that this could fit into |
Beta Was this translation helpful? Give feedback.
-
This is limited to optimization that can't be done without the help of See #1046 for previous discussion on this. In any case, a The only viable solution I can think of is to expose the |
Beta Was this translation helpful? Give feedback.
-
Per this discussion I created this pull request in Note that the It seems to me, though, that in all cases direct global bindings of everything in the WindowOrWorkerGlobalScope mixin would be preferred over the existing bindings in As far as making |
Beta Was this translation helpful? Give feedback.
-
I would like to consider the pros and cons of adding a
Global
type tojs-sys
that is returned fromjs_sys::global()
. This global type would be a wrapper over bindings to either a Window or WorkerGlobalScope and would provide the intersection of the two APIs.The motivation for this is that several projects, most recently Bevy (bevyengine/bevy#12134), want to be agnostic over whether they are running in a worker or in the main window. This has led to duplication of probing code in numerous code bases which tries to figure out at, often on each innovation, whether the global scope is a window or a worker global scope.
The argument against this is that
js-sys
should be bindings only. I would however counter that argument with the fact thatjs-sys
does go beyond just bindings. For example, it provides iter-operation with Rust iterators and bindings such asUint8Array
have special methods liketo_vec
for efficiently copying data into wasm memory.Beta Was this translation helpful? Give feedback.
All reactions