Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hoehrmann
Created April 18, 2019 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoehrmann/ca9a97ce7d2f33a8bcd73c9a434f772a to your computer and use it in GitHub Desktop.
Save hoehrmann/ca9a97ce7d2f33a8bcd73c9a434f772a to your computer and use it in GitHub Desktop.
evolveProtocol
export namespace api {
export interface Request<
> {
method: string;
params: any;
result: any;
}
export interface Notification<
> extends Request {
result: void;
}
export type Params<
T extends Request
> = T['params'];
export type Result<
T extends Request
> = T['result'];
export type Function<
T extends Request
> = (params: Params<T>) => Result<T>;
export type Interface<T extends any> = {
[M in keyof T]: api.Function<T[M]>
}
}
export namespace evolve {
export type Solution = any;
export type Metrics = any;
/**
* The [[evolve.combine]] request...
*/
export class combine implements api.Request {
method = 'evolve.combine';
params: {
/** Solutions to be combined */
solutions: Solution[];
};
result: {
solution: Solution;
};
}
export class hello implements api.Notification {
method = 'evolve.hello';
params: {
};
result: void
}
}
class Implements {
combine: evolve.combine;
hello: evolve.hello;
};
class Combiner implements api.Interface<Implements> {
combine(params: api.Params<evolve.combine>): api.Result<evolve.combine> {
return { solution: null };
}
hello(params: api.Params<evolve.hello>): api.Result<evolve.hello> {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment