-
-
Notifications
You must be signed in to change notification settings - Fork 116
Home
EDIT: This wiki is outdated and mostly refers to the V1 of the library. So beware, reader...
How we build content for the web browser has changed a lot. In addition to looking at the browser as a document reader, it is now able to run applications built with JavaScript.
The traditional web MVC architecture was based on requesting content from the server (Controller), it grabs data from your database (Model) and creates a new HTML string (View) to pass back to the browser. This pattern has continued to exist when we started building applications. Backbone JS being one of the first common frameworks. Backbone JS works very well for applications that mimics the earlier web MVC flow. Backbone.Collection and Backbone.Model is the Model, Backbone.View is the View and Backbone.Router is the Controller (MVC).
As time passed we started to create more complex applications that required new patterns. MVP and MVVM are two examples of that. They have indeed contributed to a structured approach to creating modern complex web applications, but as time passes and the sophistication of our apps just increase, we are at a point where we again need new patterns.
One of the most sophisticated web applications in the world is Facebook, and when the Facebook development team talks, you should listen. Flux is a pattern they have been talking about for quite some time now. Stores, actions and dispatchers. It was very diffuse, and still is. Developers has been implementing a lot of different solutions, their own take on what FLUX means.
Baobab is not a library inspired by Flux, but it is a library that fits with the ideas of Flux. You want a centralized hub for all your application state. It being data retrieved from the server or UI state. Using Baobab this is one single object, called a tree. Your components are able to retrieve data cursors from this tree and whenever something happens to that cursor, the component will be notified. To change state of the Baobab tree it is encouraged to use an event hub. Your components trigger events like addTodo on the event hub, and some other part of your code is responsible for listening to that event and act upon it. This decouples your components from the rest of your business logic. The components will only depend on the Baobab tree and the event hub. The rest of your business logic is behind whatever listens to the events on your event hub.
This strategy makes it very easy to create isomorphic apps, as the components can be loaded on the server without loading you complete client stack. Baobab with React JS is a great combination to build cutting edge web applications and isomorphic apps.