testing function sum and freeze
This commit is contained in:
parent
7873571d22
commit
a73d24759c
@ -197,6 +197,30 @@ export function View({
|
||||
<i18n.Translate>run gc</i18n.Translate>
|
||||
</Button>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={() => {
|
||||
return api.background.call("sum", [1, 2, 3]).then((r) => {
|
||||
console.log("SUM", r);
|
||||
});
|
||||
}}
|
||||
>
|
||||
<i18n.Translate>sum 123</i18n.Translate>
|
||||
</Button>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={() => {
|
||||
return api.background.call("freeze", 5000).then(() => {
|
||||
console.log("WAIT");
|
||||
});
|
||||
}}
|
||||
>
|
||||
<i18n.Translate>freeze 5000</i18n.Translate>
|
||||
</Button>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<Button
|
||||
variant="contained"
|
||||
|
@ -53,6 +53,14 @@ export interface ExtendedPermissionsResponse {
|
||||
}
|
||||
|
||||
export interface BackgroundOperations {
|
||||
freeze: {
|
||||
request: number;
|
||||
response: void;
|
||||
};
|
||||
sum: {
|
||||
request: number[],
|
||||
response: number,
|
||||
}
|
||||
resetDb: {
|
||||
request: void;
|
||||
response: void;
|
||||
|
@ -162,7 +162,19 @@ async function toggleHeaderListener(
|
||||
return { newValue: false };
|
||||
}
|
||||
|
||||
function freeze(time: number): Promise<void> {
|
||||
return new Promise((res, rej) => {
|
||||
setTimeout(res, time)
|
||||
})
|
||||
}
|
||||
|
||||
async function sum(ns: Array<number>): Promise<number> {
|
||||
return ns.reduce((prev, cur) => prev + cur, 0)
|
||||
}
|
||||
|
||||
const backendHandlers: BackendHandlerType = {
|
||||
freeze,
|
||||
sum,
|
||||
containsHeaderListener,
|
||||
getDiagnostics,
|
||||
resetDb,
|
||||
|
Loading…
Reference in New Issue
Block a user