Improving WA.state typings
This commit is contained in:
parent
756a495ac6
commit
84df25f863
1 changed files with 12 additions and 14 deletions
|
@ -19,8 +19,7 @@ export const initVariables = (_variables: Map<string, unknown>): void => {
|
|||
variables.set(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
setVariableResolvers.subscribe((event) => {
|
||||
const oldValue = variables.get(event.key);
|
||||
|
@ -44,19 +43,19 @@ export class WorkadventureStateCommands extends IframeApiContribution<Workadvent
|
|||
typeChecker: isSetVariableEvent,
|
||||
callback: (payloadData) => {
|
||||
setVariableResolvers.next(payloadData);
|
||||
}
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
saveVariable(key: string, value: unknown): Promise<void> {
|
||||
variables.set(key, value);
|
||||
return queryWorkadventure({
|
||||
type: 'setVariable',
|
||||
type: "setVariable",
|
||||
data: {
|
||||
key,
|
||||
value
|
||||
}
|
||||
})
|
||||
value,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
loadVariable(key: string): unknown {
|
||||
|
@ -71,7 +70,6 @@ export class WorkadventureStateCommands extends IframeApiContribution<Workadvent
|
|||
}
|
||||
return subject.asObservable();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const proxyCommand = new Proxy(new WorkadventureStateCommands(), {
|
||||
|
@ -86,7 +84,7 @@ const proxyCommand = new Proxy(new WorkadventureStateCommands(), {
|
|||
// User must use WA.state.saveVariable to have error message.
|
||||
target.saveVariable(p.toString(), value);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
},
|
||||
}) as WorkadventureStateCommands & { [key: string]: unknown };
|
||||
|
||||
export default proxyCommand;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue