Book Image

MobX Quick Start Guide

By : Pavan Podila, Michel Weststrate
Book Image

MobX Quick Start Guide

By: Pavan Podila, Michel Weststrate

Overview of this book

MobX is a simple and highly scalable state management library in JavaScript. Its abstractions can help you manage state in small to extremely large applications. However, if you are just starting out, it is essential to have a guide that can help you take the first steps. This book aims to be that guide that will equip you with the skills needed to use MobX and effectively handle the state management aspects of your application. You will first learn about observables, actions, and reactions: the core concepts of MobX. To see how MobX really shines and simplifies state management, you'll work through some real-world use cases. Building on these core concepts and use cases, you will learn about advanced MobX, its APIs, and libraries that extend MobX. By the end of this book, you will not only have a solid conceptual understanding of MobX, but also practical experience. You will gain the confidence to tackle many of the common state management problems in your own projects.
Table of Contents (17 chapters)
Title Page
Packt Upsell

A few other APIs

There are some miscellaneous APIs that are provided by MobX that are not that frequently used. It is still worth mentioning them here for the sake of completeness. 

Querying the reactive system

When dealing with the various abstractions in MobX (observables, actions, reactions), it is sometimes useful to know if a certain object, function, or value is of a certain kind. MobX has a set of isXXX APIs that help you to determine the type of the value:

  • isObservableObject(thing), isObservableArray(thing), isObservableMap(thing): Tells you whether the passed in value is an observable object, array, or map
  • isObservable(thing) and isObservableProp(thing, property?): Similar to the preceding point but more generalized check for an observable value
  • isBoxedObservable(thing): Whether the value is a boxed observable
  • isAction(func): Returns true if the function is wrapped by an action
  • isComputed(thing) and isComputedProp(thing, property?): Checks whether the value is a computed property