I'm starting to work with Appwrite and would like to better understand the execution context of Functions;
Could I make a shared folder between functions and place them in a single repository?
For example, in the following structure:
└── functions ├── make_dove_appear │ └── main.dart ├── make_rabbit_appear │ └── main.dart └── shared └── my_magic_hat.dart
The main.dart file from my make_rabbit_appear folder/function, could you import my_magic_hat.dart from a subfolder of the directory?
import '../shared/my_magic_hat.dart';
void main() {
// Loaded from the shared sub-folder?
final magicHat = MyMagicHat();
magicHat.makeAnimalAppear(
AnimalAvailable.rabbit,
);
}
See that I will register two different functions. They will be called from different places and will have different functions.
But they used some common resource.
If you deploy function and specify make_dove_appear as the folder, only that folder is added into the container for building
That said, you can share code by using symlinks to make it as if the common folder was in the folder being deployed
And then put an entry in your pub spec that points to that path
So something like:
- functions
- dependencies
- common <--- symlink
- lib
- main.dart
- pubspec.yaml
- dependencies
And pubspec has
dependencies:
common:
path: dependencies/common
It's pretty clear now! Thank you for your time and tip!
Recommended threads
- Tips for Debugging Appwrite Functions Lo...
Hi everyone! 👋 I have an Appwrite Function running locally with Docker, but I’m struggling to debug it because execution doesn’t reach the breakpoints I set. ...
- AttributeError: 'Context' object has no ...
I'm getting an error executing my function. I'm not able to replicate this locally since I have to use a mock context. Is there a way to debug this kind of erro...
- SyntaxError: The requested module 'node-...
I am trying to use appwrite functions and in the function i am creating rows but i got this error when i executed the funtion. As i checked docs there TablesDB...