From df9f16e33b1d537f53365817285a4b617ab97029 Mon Sep 17 00:00:00 2001 From: Jeff Keen Date: Wed, 1 Nov 2023 20:58:20 -0500 Subject: [PATCH] chore: add some hidden examples for debugging to the docs --- tests/dummy/app/components/docs/queued.hbs | 19 ++++++++++ tests/dummy/app/components/docs/queued.js | 41 +++++++++++++++++++++ tests/dummy/app/router.js | 1 + tests/dummy/app/templates/docs/advanced.md | 3 -- tests/dummy/app/templates/docs/debugging.md | 5 +++ 5 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 tests/dummy/app/components/docs/queued.hbs create mode 100644 tests/dummy/app/components/docs/queued.js create mode 100644 tests/dummy/app/templates/docs/debugging.md diff --git a/tests/dummy/app/components/docs/queued.hbs b/tests/dummy/app/components/docs/queued.hbs new file mode 100644 index 00000000..bb5dd3c7 --- /dev/null +++ b/tests/dummy/app/components/docs/queued.hbs @@ -0,0 +1,19 @@ + + + + {{#if (sound-is-playing (current-sound))}} +

{{get (current-sound) 'url'}}

+ + + {{else}} + + {{/if}} + +
+ + +
\ No newline at end of file diff --git a/tests/dummy/app/components/docs/queued.js b/tests/dummy/app/components/docs/queued.js new file mode 100644 index 00000000..e88b6b56 --- /dev/null +++ b/tests/dummy/app/components/docs/queued.js @@ -0,0 +1,41 @@ +import Component from '@glimmer/component'; +import { inject as service } from '@ember/service'; +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; +// BEGIN-SNIPPET queued.js +export default class Queued extends Component { + @service stereo; + + @tracked identifier; + @tracked queue = []; + + @action + async playSound() { + this.queue = [ + '/sounds/attention.mp3', + '/sounds/internet-on-computers.mp3', + 'https://kut.streamguys1.com/kut-web.aac', + ]; + + let sound = await this.playNext(); + sound.audioElement.setAttribute( + 'id', + `id-${Math.floor(Math.random() * 10000)}` + ); + + this.stereo.on('audio-ended', ({ sound }) => { + console.log(sound.audioElement); + this.playNext(); + }); + } + + async playNext() { + let next = this.queue.shift(); + if (next) { + let { sound } = await this.stereo.play(next); + + return sound; + } + } +} +// END-SNIPPET queued.js diff --git a/tests/dummy/app/router.js b/tests/dummy/app/router.js index a49311fe..237efb9f 100644 --- a/tests/dummy/app/router.js +++ b/tests/dummy/app/router.js @@ -24,6 +24,7 @@ Router.map(function () { this.route('volume'); this.route('advanced'); this.route('testing'); + this.route('debugging'); }); this.route('diagnostic', function () { diff --git a/tests/dummy/app/templates/docs/advanced.md b/tests/dummy/app/templates/docs/advanced.md index ac3084dc..b8d5dfee 100644 --- a/tests/dummy/app/templates/docs/advanced.md +++ b/tests/dummy/app/templates/docs/advanced.md @@ -1,5 +1,2 @@ Modifiers to create position controls - -Proxies - diff --git a/tests/dummy/app/templates/docs/debugging.md b/tests/dummy/app/templates/docs/debugging.md new file mode 100644 index 00000000..30a6fc39 --- /dev/null +++ b/tests/dummy/app/templates/docs/debugging.md @@ -0,0 +1,5 @@ +Proxies + + +Queued +