## Table Of Contents - [Bootstrapping Application State](#bootstrapping-application-state) - [1. Register Handlers](#1-register-handlers) - [2. Kick Start Reagent](#2-kick-start-reagent) - [3. Loading Initial Data](#3-loading-initial-data) - [Getting Data Into `app-db`](#getting-data-into-app-db) - [The Pattern](#the-pattern) - [Scales Up](#scales-up) - [Cheating - Synchronous Dispatch](#cheating---synchronous-dispatch) - [Loading Initial Data From Services](#loading-initial-data-from-services) ## Bootstrapping Application State To bootstrap a re-frame application, you need to: 1. register handlers - subscription (via `reg-sub`) - events (via `reg-event-db` or `reg-event-fx`) - effects (via `reg-fx`) - coeffects (via `reg-cofx`) 2. kickstart reagent (views) 3. Load the right initial data into `app-db` which might be a `merge` of: - Some default values - Values stored in LocalStorage - Values obtained via service calls to server - etc, etc Point 3 is the interesting bit and will be the main focus of this page, but let's work our way through them ... ## 1. Register Handlers re-frame's various handlers all work in the same way. You declare and register your handlers in the one step, like this "event handler" example: ```clj (re-frame/reg-event-db ;; event handler will be registered automatically :some-id (fn [db [_ value]] ... do some state change based on db and value )) ``` As a result, there's nothing further you need to do because handler registration happens as a direct result of loading the code (presumably via a `