New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: syscall/js: Add SetSymbol
method on js.Value
#62339
Comments
CC @golang/js |
Thanks for your proposal. Could you elaborate a little on what you have to do today? I'm just trying to understand exactly what the benefit is here. Do you have a practical example which would be greatly simplified with this change? Thanks! |
yes, so basically, I'm making go channel iterable in js. Example is at https://github.com/kmcsr/mcla/blob/main/cmds/mcla_wasm/utils.go#L67 |
Without symbols when I want to iter it, I have to call let value;
while(!({value} = await iter.next()).done){
/* do something with value */
} if with iterator symbol, I can use for await (let value of iter){
/* do something with value */
} |
As you can see, the first example while(true){
let res = await iter.next()
if(res.done){
break
}
let value = res.value
/* do something with value */
} |
@johanbrandhorst Any progress? |
No one is working on this as far as I know. If you want to work on this, feel free to experiment with it. |
…mbol Support set symbols on an object. For golang#62339.
Change https://go.dev/cl/555417 mentions this issue: |
Thanks for opening a CL, I think this has to go through the proposal review process before we can merge it, but it's a great start! I think this sounds like a reasonable addition to the |
Further proposal: Is it necessary to wrap an async channel in std? so other people do not need to write same logic again and again |
I'm not sure what you mean - in any case, please write a separate issue for this proposal. |
This method should works as same as
js.Value.Set
, but it usesSymbol
as the key.It's useful because we can use more js syntax sugar with symbols, such as
for ... of
, and we don't have to write extra javascripts to wrap them.A suggestion signature:
The text was updated successfully, but these errors were encountered: