Skip to content

Commit 1339c2c

Browse files
author
amandaesmith3
committed
add more comments
1 parent 1f2ae19 commit 1339c2c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/components/global/Playground/index.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@ export default function Playground({
244244
const setAndSaveMode = (mode: Mode) => {
245245
localStorage.setItem(MODE_STORAGE_KEY, mode);
246246
setIonicMode(mode);
247+
248+
/**
249+
* Tell other playgrounds on the page that the mode has
250+
* updated, so they can sync up.
251+
*/
247252
window.dispatchEvent(
248253
new CustomEvent(MODE_UPDATED_EVENT, {
249254
detail: mode,
@@ -265,6 +270,10 @@ export default function Playground({
265270
*/
266271
blockElementScrollPositionUntilNextRender(tab);
267272

273+
/**
274+
* Tell other playgrounds on the page that the framework
275+
* has updated, so they can sync up.
276+
*/
268277
window.dispatchEvent(
269278
new CustomEvent(USAGE_TARGET_UPDATED_EVENT, {
270279
detail: target,
@@ -400,6 +409,10 @@ export default function Playground({
400409
io.observe(hostRef.current!);
401410
});
402411

412+
/**
413+
* Listen for any playground on the page to have its mode or framework
414+
* updated so this playground can switch to the same setting.
415+
*/
403416
useEffect(() => {
404417
window.addEventListener(MODE_UPDATED_EVENT, (e: CustomEvent) => {
405418
const mode = e.detail;

0 commit comments

Comments
 (0)