RFC: New Denops
interface for passing AbortSignal
#424
lambdalisue
started this conversation in
Ideas
Replies: 1 comment
-
I realized that by extending the interface as follows, we could support signal while maintaining backward compatibility. export interface Denops {
// ...
redraw(force?: boolean): Promise<void>;
redraw(params: { force?: boolean, signal?: AbortSignal }): Promise<void>;
call(fn: string, ...args: unknown[]): Promise<unknown>;
call(params: { fn: string, args: unknown[], signal?: AbortSignal }): Promise<unknown>;
batch(...calls: [string, ...unknown[]][]): Promise<unknown[]>;
batch(params: { calls: [string, ...unknown[]][], signal?: AbortSignal }): Promise<unknown[]>;
cmd(cmd: string, ctx?: Context): Promise<void>;
cmd(params: { cmd: string, ctx?: Context, signal?: AbortSignal }): Promise<void>;
eval(expr: string, ctx?: Context): Promise<unknown>;
eval(params: { expr: string, ctx?: Context, signal?: AbortSignal }): Promise<unknown>;
dispatch(name: string, fn: string, ...args: unknown[]): Promise<unknown>;
dispatch(params: { name: string, fn: string, args: unknown[], signal?: AbortSignal }): Promise<unknown>;
} Additionally, I came to the conclusion that the signal parameter has limited usefulness in methods other than dispatch that send commands to Vim. This is because Vim itself can’t handle signal directly, so its main practical application would be for canceling the communication process. For consistency, I do plan to apply similar changes to other methods in the interface, but they will likely be rarely used. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Related to #415
To pass
AbortSignal
to methods ofDenops
, I'm wondering a new interface likeBut this is an interface breaking change that we should try hard to avoid while users may want to use denops plugins that followed or doesn't followed this breaking change in same time.
So we may need to add new methods like
But you know, it looks horrible. Does anyone has more brilliant idea for this?
Beta Was this translation helpful? Give feedback.
All reactions