From 9268db733876e89ae3e3b34b09dbd2c781e1f20f Mon Sep 17 00:00:00 2001 From: Scotty Simpson Date: Tue, 23 Apr 2019 07:35:11 -0700 Subject: [PATCH] simpler, more efficient example --- .../17-module-context/01-sharing-code/text.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/site/content/tutorial/17-module-context/01-sharing-code/text.md b/site/content/tutorial/17-module-context/01-sharing-code/text.md index 9081b18dce..fa0194c896 100644 --- a/site/content/tutorial/17-module-context/01-sharing-code/text.md +++ b/site/content/tutorial/17-module-context/01-sharing-code/text.md @@ -10,7 +10,7 @@ We can do that by declaring a ` ``` @@ -18,13 +18,12 @@ It's now possible for the components to 'talk' to each other without any state m ```js onMount(() => { - elements.add(audio); - return () => elements.delete(audio); + currentPlayer = audio; + return () => currentPlayer = null; }); function stopOthers() { - elements.forEach(element => { - if (element !== audio) element.pause(); - }); + if (currentPlayer !== audio) currentPlayer.pause(); + currentPlayer = audio; } -``` \ No newline at end of file +```