tdl icon indicating copy to clipboard operation
tdl copied to clipboard

IAsyncTDLibJSON is not used anywhere

Open IlyaSemenov opened this issue 5 years ago • 2 comments

Currently, IAsyncTDLibJSON doesn't seem to be used at all. tdl.Client wants non-async ITDLibJSON and never waits for promises returned by e.g. execute(client: null | TDLibClient, query: Object): Promise<Object | null>.

I am creating an async (RPC) implementation of tdlib and the typings are therefore all wrong.

What do you say if the two interfaces are merged, all functions are converted to be returning AsyncOrSync e.g. AsyncOrSync<Object | null> and tdl.Client will always await the result?

IlyaSemenov avatar Dec 28 '19 10:12 IlyaSemenov

Ah, that would mean that tdl.Client's couldn't be anymore defined as e..g execute: Execute...

IlyaSemenov avatar Dec 28 '19 10:12 IlyaSemenov

Yes, the async interface is not used.

I am creating an async (RPC) implementation of tdlib

Initially I wanted to make the wrapper fully async for cases like you describe, but in the end it has never been implemented.

The solution is either always return promises (so that await is always required) or complicate the typings so that there would be Client<'sync'> (accepts the sync interface) and Client<'async'> (accepts the async one) types.

eilvelia avatar Dec 29 '19 12:12 eilvelia