Created
April 18, 2019 23:51
-
-
Save hoehrmann/ca9a97ce7d2f33a8bcd73c9a434f772a to your computer and use it in GitHub Desktop.
evolveProtocol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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