mirror of
https://github.com/Heretek-AI/GDevelop.git
synced 2026-07-22 01:55:25 -04:00
1d5eb8e529
Only show in developer changelog
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
namespace gdjs {
|
|
export namespace evtTools {
|
|
export namespace firebaseTools {
|
|
/**
|
|
* Firebase Functions Event Tools.
|
|
* @namespace
|
|
*/
|
|
export namespace functions {
|
|
/**
|
|
* Call an http function.
|
|
* @param httpFunctionName - The name of the function to call
|
|
* @param [parameters] - Parameters for the function either as a string.
|
|
* @param {gdjs.Variable} [callbackValueVariable] - The variable where to store the result.
|
|
* @param {gdjs.Variable} [callbackStateVariable] - The variable where to store if the operation was successful.
|
|
*/
|
|
export const call = (
|
|
httpFunctionName: string,
|
|
parameter: string,
|
|
callbackValueVariable?: gdjs.Variable,
|
|
callbackStateVariable?: gdjs.Variable
|
|
) =>
|
|
firebase
|
|
.functions()
|
|
.httpsCallable(httpFunctionName)(parameter)
|
|
.then((response) => {
|
|
if (callbackValueVariable)
|
|
callbackValueVariable.fromJSObject(response.data);
|
|
|
|
if (typeof callbackStateVariable !== 'undefined')
|
|
callbackStateVariable.setString('ok');
|
|
})
|
|
.catch((error) => {
|
|
if (typeof callbackStateVariable !== 'undefined')
|
|
callbackStateVariable.setString(error.message);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|