mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-30 02:37:46 +03:00
clean client
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
f9907655a9
commit
6d4d11407d
@ -63,6 +63,14 @@ class ClientImpl implements Client {
|
|||||||
await Promise.all([this.conn.tx(tx), this.model.tx(tx)])
|
await Promise.all([this.conn.tx(tx), this.model.tx(tx)])
|
||||||
this.notify?.(tx)
|
this.notify?.(tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async updateFromRemote (tx: Tx): Promise<void> {
|
||||||
|
if (tx.objectSpace === core.space.Model) {
|
||||||
|
this.hierarchy.tx(tx)
|
||||||
|
await this.model.tx(tx)
|
||||||
|
}
|
||||||
|
this.notify?.(tx)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,7 +79,7 @@ class ClientImpl implements Client {
|
|||||||
export async function createClient (
|
export async function createClient (
|
||||||
connect: (txHandler: TxHander) => Promise<Storage>
|
connect: (txHandler: TxHander) => Promise<Storage>
|
||||||
): Promise<Client> {
|
): Promise<Client> {
|
||||||
let client: Client | null = null
|
let client: ClientImpl | null = null
|
||||||
let txBuffer: Tx[] | undefined = []
|
let txBuffer: Tx[] | undefined = []
|
||||||
|
|
||||||
const hierarchy = new Hierarchy()
|
const hierarchy = new Hierarchy()
|
||||||
@ -81,8 +89,8 @@ export async function createClient (
|
|||||||
if (client === null) {
|
if (client === null) {
|
||||||
txBuffer?.push(tx)
|
txBuffer?.push(tx)
|
||||||
} else {
|
} else {
|
||||||
console.log('handler got ', tx)
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||||
client.notify?.(tx)
|
client.updateFromRemote(tx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user