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.
- Trigger by event. https://appwrite.io/docs/events#functions-events You can set the event trigger to be the first function. You can see here some example https://discord.com/channels/564160730845151244/1097977347795337318/1097979530943139952 In this option you'll pass only the information that was returned from the first function
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
and syntactically, how would i pass the data to functions.createExecution(<function id>)
?
Like so
functions.createExecution('[FUNCTION_ID]','Data');
// OR
functions.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
All right that answers my question. thank you!
[SOLVED] How to execute a function from another function?
Recommended threads
- Different appwrite IDs are getting expos...
File_URL_FORMAT= https://cloud.appwrite.io/v1/storage/buckets/[BUCKET_ID]/files/[FILE_ID]/preview?project=[PROJECT_ID] I'm trying to access files in my web app...
- Got message for auto payment of 15usd fo...
how did this happen? 1. i claimed my 50usd credits via jsm hackathon - https://hackathon.jsmastery.pro/ 2. it asked me which org. to apply the credits on, i se...
- Invalid document structure: missing requ...
I just pick up my code that's working a week ago, and now I got this error: ``` code: 400, type: 'document_invalid_structure', response: { message: 'Inv...