Rank 1: Thread
Can i fire a custom event from one function, and then listen to it from another one? and pass data from the caller function to the callee function?
I'm using JS
Votes
1
Replies
9
Participants
Unknown
Messages
10
Rank 1: Thread
Can i fire a custom event from one function, and then listen to it from another one? and pass data from the caller function to the callee function?
I'm using JS
You have few option to do so:
1. Via server/client side SDK
https://appwrite.io/docs/client/functions?sdk=web-default#functionsCreateExecution
https://appwrite.io/docs/server/functions?sdk=nodejs-default#functionsCreateExecution
In this option you can pass any data you want.
Rank 1: Thread
so does createExecution fire the function whose id was passed into it? or does it create a custom execution event i can subscribe to
createExecution will trigger direct execution of the function.
In the data you can pass whatever you want
When you're listening to function event then your function will execute every time your function do something, and you can check then the data you got from the function
Rank 1: Thread
and syntactically, how would i pass the data to functions.createExecution(<function id>)?
Like so
functions.createExecution('[FUNCTION_ID]','Data');// ORfunctions.createExecution('[FUNCTION_ID]',JSON.stringify({object:'value'}));For now you can pass only string that's why you'll need to stringify your object
And inside your function you can parse the json
Rank 1: Thread
All right that answers my question. thank you!
[SOLVED] How to execute a function from another function?