FrintJS
Published in

FrintJS

Thinking in Apps with FrintJS

Image by Jake Page

Why create Child Apps?

All applications, given enough time, grow big. Concept of Child Apps in FrintJS help you break your large monolithic applications into smaller isolated Apps, that you can load and register (and optionally render) on demand.

An example application

Think of a big project management application. It may have these features:

  • Users management
  • Todo list management
  • Calendar for events management

Let’s break it down into smaller Apps

If you were building this big application with FrintJS, you could break it down into multiple Apps as follows:

  • Root: The primary base of the application (Root App)
  • Users: Child App for handling users
  • Todos: Child App for all things todos
  • Events: Child App for managing everything related to calendar/events

Creating and registering Child Apps

Let’s create our Root App first:

import { createApp } from 'frint';const RootApp = createApp({
name: 'MyRootApp',
providers: [
{
name: 'foo',
useValue: 'foo value here',
},
],
});
const app = new RootApp();
const TodosApp = createApp({
name: 'Todos',
});
app.registerApp(TodosApp);
const todosApp = app.getAppInstance('Todos');

Passing providers down from Root App to Child Apps

It is very likely that you have some really important providers defined in your Root App, that you would like your Child Apps to access.

import { createApp } from 'frint';const RootApp = createApp({
name: 'MyRootApp',
providers: [
{
name: 'foo',
useValue: 'foo value here',
cascade: true,
},
],
});
const app = new RootApp();
const todosApp = app.getAppInstance('Todos');todosApp.get('foo'); // `foo value here`

What about rendering Child Apps?

I intentionally didn’t touch this topic in this post, since this would involve dealing with rendering libraries like React or Vue.js.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store