Journey of building a Saas product – Frontend SPA (MithrilJS)
Front-end framework has plenty of alternative to choose from. React, Angular, Vue, and many more. Despite that I have opt to use MithrilJS.
It started way back when front-end framework was just about to become an “in” thing. I was choosing for framework to work on. Bare in mind, React as so new at that time, and Angular was having tons of stability issue at that time.
Anyhow, with much consideration, I have used this without much regret, except that occasionally, so wish that has more community build in plugin/extension/library support. Still, is not hard to setup mithril one of a kind by referring back to react implementation, I am able to get the similar usage out of any third-party library that is available.
Personally, I do feel this is the underdog that should not be taken lightly. Looking back, most of my decision on other technology choice is not those of super popular.
The easiest way to get started is by referring to some others framework that is more establish. In our case, we refer to Flarum as they also uses mithril as their core rendering engine.
Just like any application, we need to have life-cycle of the application start, up till the component creation and destruction. MithrilJS life-cycle is complete and easy to use and understand. Couple with the the well define concept from flarum using service to boot(render) and managing all the background and global values.
Here is a screen show of my index.js. Which is a sequence of services in sequence to startup.
import App from 'util/App'; import boot from 'service/boot'; import routes from 'service/routes'; import request from 'service/request'; import session from 'service/session'; import setting from 'service/setting'; import allow from 'service/allow'; window.app = new App(); app.initializer('routes', routes); app.initializer('request', request); app.initializer('session', session); app.initializer('setting', setting); app.initializer('allow', allow); app.initializer('boot', boot); app.boot(); // Run all the initializers!
The main component of a SPA is routing. That is the navigation of pages that you have build. Well, mithril got that cover as well for you as well. It is dead simple. Not much need to be done except to work on the UI for the business. There is even RouteResolver to protect certain route from accessing unwanted page.
This framework is light and complete for my standard for building application.