API Broadcast "any" bug

There seems to be a bug with IDE_Morph.prototype.broadcast() with the new upvar in the revamped version of
untitled script pic(1)

This project demonstrates it (you'll need to enable JavaScript, or just manually broadcast a message via the JavaScript console).

When you run a normal "Broadcast" block (even with a dynamic name), the "when I receive [any message]" block correctly passes the contents of the message.

But when you run ide.broadcast("Message"), the "when I receive [any message]" block throws an error:

Screen Shot 2021-12-28 at 2.34.32 PM

It doesn't count as a Snap! bug if you can write JavaScript code that doesn't work. That's a bug in your JS code! Of course you can write JS code that won't work, and there's no possible way we can anticipate every possible buggy JS code you might write.

Sorry! This is based off the definition in src/api.js. I thought these functions were relatively public for developers for extensions, etc (at least, more public than the other internal functions in terms of stability over time)

This is what we've been using for message passing in the EDC microworld projects prior to Snap*!* 7, so I wasn't sure if this function was meant to be updated to stay compatible. I can keep exploring ways we can work around it on our end!

If your code is embedded in Snap!,
untitled script pic - 2021-12-29T002342.735
till/if api.js gets updated.

@dardoro thank you!

After a little more poking around, I think I figured out a fix for api.js - see here.

The changes come directly from the definition of doBroadcast() in threads.js, with like two minor modifications to match variable names in the JS.

EDIT: Fixed the link and changed one line to pass on the optional callback parameter. ide.broadcast() with a callback probably needs more testing to make sure it works as expected.

Ah, okay, I didn't realize you were calling an official API, sorry!

If you have a fix, file a PR. Thanks!

Thank you! Just did.