rename communit callbacks
This commit is contained in:
parent
f9ff7cc92f
commit
e186ec7e79
|
@ -27,7 +27,7 @@ export class Community {
|
||||||
public description!: CommunityDescription
|
public description!: CommunityDescription
|
||||||
public chats: Map<string, Chat>
|
public chats: Map<string, Chat>
|
||||||
#members: Map<string, Member>
|
#members: Map<string, Member>
|
||||||
#descriptionCallbacks: Set<(description: CommunityDescription) => void>
|
#callbacks: Set<(description: CommunityDescription) => void>
|
||||||
|
|
||||||
constructor(client: Client, publicKey: string) {
|
constructor(client: Client, publicKey: string) {
|
||||||
this.client = client
|
this.client = client
|
||||||
|
@ -37,7 +37,7 @@ export class Community {
|
||||||
|
|
||||||
this.chats = new Map()
|
this.chats = new Map()
|
||||||
this.#members = new Map()
|
this.#members = new Map()
|
||||||
this.#descriptionCallbacks = new Set()
|
this.#callbacks = new Set()
|
||||||
}
|
}
|
||||||
|
|
||||||
public async start() {
|
public async start() {
|
||||||
|
@ -221,9 +221,7 @@ export class Community {
|
||||||
this.description = description
|
this.description = description
|
||||||
|
|
||||||
// callback
|
// callback
|
||||||
this.#descriptionCallbacks.forEach(callback =>
|
this.#callbacks.forEach(callback => callback({ ...this.description }))
|
||||||
callback({ ...this.description })
|
|
||||||
)
|
|
||||||
|
|
||||||
// Chats
|
// Chats
|
||||||
// handle
|
// handle
|
||||||
|
@ -234,10 +232,10 @@ export class Community {
|
||||||
}
|
}
|
||||||
|
|
||||||
public onChange = (callback: (description: CommunityDescription) => void) => {
|
public onChange = (callback: (description: CommunityDescription) => void) => {
|
||||||
this.#descriptionCallbacks.add(callback)
|
this.#callbacks.add(callback)
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
this.#descriptionCallbacks.delete(callback)
|
this.#callbacks.delete(callback)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue