Make the speaker retain its last spoken message
This commit is contained in:
parent
5036259d75
commit
8161b80081
1 changed files with 5 additions and 1 deletions
|
@ -2,16 +2,20 @@ class Speaker {
|
|||
#callbacks = new Set()
|
||||
#immediate
|
||||
#scheduled = []
|
||||
#current
|
||||
|
||||
constructor(immediate) {
|
||||
constructor(immediate, current=[]) {
|
||||
this.#immediate = immediate
|
||||
this.#current = current
|
||||
}
|
||||
|
||||
listen(callback) {
|
||||
this.#callbacks.add(callback)
|
||||
return this.#current
|
||||
}
|
||||
|
||||
speak(...args) {
|
||||
this.#current = args
|
||||
if (this.#immediate) {
|
||||
for (let callback of this.#callbacks) {
|
||||
callback(...args)
|
||||
|
|
Loading…
Reference in a new issue