Then after everything got installed, let me go inside this workspace folder and install Now or Rack Native package. Then enter command to generate a Rack Native app. I'll name this app as mobile.
If I open the Rack Summit workspace folder, on the apps, there are currently four folders. It has the web app and mobile app I just created and E2E folders. If I enter nx serve web, you will serve up the default Rack web app. Meanwhile to run the mobile app. In terminal, I enter the command nx run os. In a different terminal, I enter nx run android. You will serve up the ios and android apps in simulator respectively.
Now let's look at the dependency graph. In terminal, enter nx graph. Enter nx graph. I should see the dependency graph of this project. Notice there's nothing shared between web and mobile apps.
Then let's create a shared library. In terminal, enter the command nx generate live. For this example, I'm going to call this library constants. Under the lab's folder, I should now see a constants folder got created. Inside index.ts file, I'm going to create a constant variable called title.
Then let me go to the web app folder. First, I'm going to import the title variable from the constant library. After that, I'm going to pass the title constants to the title prop. If I launch the web app again, I should notice that title got changed. Same goes for the mobile app. I should also be able to import from the shared library and change the title to be from this library.
If I open up the dependency graph again, I should see that both mobile and web import from this constants library. Sharing a constant variable does not seem to be that useful. However, imagine what could be shared or the non-UI related code could be shared. For example, business logic and state management. This way ensure feature parity that for same features, developers don't need to implement same logic twice. It could exist only once inside a shared library.
Essentially, with help from Next, the project setup would look like this. For the apps, you only contain UI code. For the non-UI related code, we could create libraries for those. For more information, you could check out my blog post linked on the bottom of the page. The end.
Comments