My notebook (Doppler Laser Cooling / ccesare | Observable) has a cell named “graphic” that works well, but when I try to export via Export → Embed Cells, I see “graphic = undefined” as soon as I click the preview. (I’ve forked this from another notebook for ease of sharing and making changes.)
Given that it used to work, I was thinking this must be due to a change in how Observable provides these embeds. But maybe I just was lucky before and there is actually something wrong with the notebook? That wouldn’t explain why it works fine in the notebook itself but fails when embedded.
Note that your variable mutable paused starts off as true, and that’s the value that it probably has when graphic is loaded. Somewhere along the line, mutable pause is set to false and, since your yield is statement is inside a while(!pased) loop, the result is undefined. The quick fix is to embed paused as well.
I can’t verify that this “used to work” but there certainly can be some variability when you’ve got this kind of well hidden side effect, so I can believe that it might have.
We published a major update to embeds at the end of last year. One of the less advertised changes was that we are now more explicit about which cells to run in an embed. What that means in detail:
In the old version, all cells would run (“compute”) in the background, regardless of whether they were actually selected or were dependencies (“upstream cells”) of selected cells.
In the new version, in addition to the selected cells we only compute cells that depend on any of the selected cells (“downstream cells”), directly or indirectly. Doing so lets us account for most side effects that other cells may produce.
@mcmcclur helpfully pointed out that in your case one of the side effects involves a mutable. I would have expected that to work, and will need take a closer look to figure out if we need to make changes to our detection of downstream cells.