Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Knowing when some function is used in frontend/backend code. #57

Open
marcglasberg opened this issue Mar 5, 2024 · 3 comments
Open
Labels
triaging Initial investigation into the issue

Comments

@marcglasberg
Copy link

marcglasberg commented Mar 5, 2024

When I have some function that's used in both the frontend and the backend, it may need to know if it's running in the client (my_app/lib/) or in the Celest dir (my_app/celest/).

Just knowing this fact is important, but it also helps me to choose between using celest or celestBackend when I want to check the CelestEnvironment.

String whereAmI() {
     if (celest.running == CelestRunning.clientCode) {
        if (celest.currentEnvironment == CelestEnvironment.local) return "Client code, local";
        if (celest.currentEnvironment == CelestEnvironment.production)  return "Client code, prod";
     }   
     else if (celest.running == CelestRunning.serverCode) {
        if (celestBackend.currentEnvironment == CelestEnvironment.local) return "Celest code, local";
        if (celestBackend.currentEnvironment == CelestEnvironment.production)  return "Celest code, prod";
     }
}
@dnys1 dnys1 added the triaging Initial investigation into the issue label Mar 5, 2024
@dnys1
Copy link
Member

dnys1 commented Mar 5, 2024

Interesting use case! Hmm.. I will need to give this one some thought.

@dnys1
Copy link
Member

dnys1 commented Mar 6, 2024

@marcglasberg One trick you could do right now is check if you're running in Flutter:

const runningInFlutter = bool.fromEnvironment('dart.library.ui');

@marcglasberg
Copy link
Author

Nice trick!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaging Initial investigation into the issue
Projects
None yet
Development

No branches or pull requests

2 participants