Ash Typescript with React Native
Ash typescript sounds promising, but there is one thing I'm not sure if I understand.
If you do a React frontend that live within your assets folder, this works great since the generated files are there.
But if I have a React-Native app in a separate repo, would I have to take the generated typescript file and manually put it in my React-Native repo each time I codegen?
I see there is an
output_file config. I guess I could have a monorepo and set the output file to output outside the ash project into a shared folder or something?
Has anybody worked with ash_typescript with a separated frontend?6 Replies
If you are building your frontend in a separate repo, I would go for something like this:
For local development, in your backend repo set ash_typescript's output_file setting to point to the location where you would like the generated file to be located in your frontend repo, for example something like
../my_frontend_app/src/ash_typescript.generated.ts
You don't necessarily need a monorepo, but that would definitely work as well 😎
If you are building and deploying both projects yourself, a setup like above would probably do the job.
For deploying with CI/CD pipelines, I would recommend that every time the backend is built, the generated typescript file is saved as a build artifact, and when building the frontend, you always fetch that build artifact and place it inside your code before you start a build. Then you will ensure that your frontend builds are always in sync with your latest deployed backend.Ok yeah this make sense!
While I have you here, 🙂
I never worked with an RPC workflow before, would this be a good fit if I need my app to be available offline?
I guess i would need to create a layer above the generated RPC calls that detect if i'm online and if not get the result from a cache instead?
But it seems like it would defeat the purpose of having generated functions for my api then if i need to wrap them
Hm, I haven't given that scenario much thought at all so far really 😅
But technically it just results in regular http calls being made in the end, so you could use web workers to intercept those http calls, separating them by what is contained in the payload, or just some higher level library to wrap the function calls themselves
Oh thats right, i guess i could use something like tanstack-query!
Use it something like this since the exported functions are promises

Yeah, there is a link to a demo repo in the README.md btw, that uses it for pagination etc via tanstack 😎
oh cool i will check it out, Thanks 🙂