Skip to content

syscall/js.FuncOf support #367

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

Merged
merged 2 commits into from
May 27, 2019
Merged

syscall/js.FuncOf support #367

merged 2 commits into from
May 27, 2019

Conversation

aykevl
Copy link
Member

@aykevl aykevl commented May 21, 2019

No description provided.

@aykevl
Copy link
Member Author

aykevl commented May 21, 2019

Of course, this doesn't work well with Go 1.11 because js.FuncOf was only added in Go 1.12...

@aykevl
Copy link
Member Author

aykevl commented May 22, 2019

I was thinking that it may be better to add a new example that uses js.FuncOf instead of modifying the export example. That would also make it easier to fix the compilation error here.

@johanbrandhorst
Copy link
Member

I was thinking that it may be better to add a new example that uses js.FuncOf instead of modifying the export example. That would also make it easier to fix the compilation error here.

I think we could add it to the non-export example without making it too busy.

@aykevl aykevl marked this pull request as ready for review May 24, 2019 13:31
@aykevl
Copy link
Member Author

aykevl commented May 24, 2019

New attempt, now more carefully written.

@aykevl
Copy link
Member Author

aykevl commented May 24, 2019

I've now split the examples, it seems cleaner to me (although there is a bit of duplication). It clearly shows both ways of doing the same thing which may be useful.

@johanbrandhorst @justinclift any thoughts?

Rename panic functions to be runtime.nilPanic, runtime.lookupPanic, and
runtime.slicePanic.
@aykevl aykevl changed the title WIP syscall/js.FuncOf support syscall/js.FuncOf support May 24, 2019
@aykevl
Copy link
Member Author

aykevl commented May 26, 2019

I have updated the callback example to be more in a functional style. Not sure whether this example is much better but would like to hear some thoughts on it.

Copy link
Member

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

<h1>WebAssembly</h1>
<p>Add two numbers, using WebAssembly:</p>
<input type="number" id="a" value="0" /> + <input type="number" id="b" value="0" /> = <input type="number"
id="result" readonly />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a trivial thing, but maybe have the result input all be on one line?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Yes that's a bit unclean. (Probably some unintended auto-wrapping by my editor?)

@justinclift
Copy link
Member

LGTM too.

.Set("oninput", updater(&a)) is interesting too. Didn't know that was a thing, having only mucked around with .addEventListener("mousedown", someFunction) before. 😄

@aykevl aykevl merged commit eb1d834 into dev May 27, 2019
@aykevl aykevl deleted the wasm-funcof branch May 27, 2019 11:36
@aykevl
Copy link
Member Author

aykevl commented May 27, 2019

Yes, you can also set events by setting the on-prefixed property. However, this is generally discouraged for many things because it overwrites the old event handler. addEventListener was added specifically to avoid that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants