@@ -41,20 +41,31 @@ const DEFAULT_STATE = {
4141 * The Driver is a framework agnostic state manager for App Search apps. Meaning, 
4242 * it is the source of truth for state in this React App, but it has no 
4343 * dependencies on React itself. 
44+  * 
45+  * The public interface of the Driver can be thought about in the following 
46+  * way: 
47+  * 
48+  * Ways to GET state: 
49+  * - getState - Get the initial app state 
50+  * - subscribeToStateChanges - Get updated state whenever it changes 
51+  * 
52+  * Ways to SET state, or "Actions" as we refer to them elsewhere 
53+  * - addFilter, etc, will typically update the state and trigger new queries 
54+  * 
4455 */ 
4556export  default  class  AppSearchDriver  { 
4657 state  =  DEFAULT_STATE ; 
4758
4859 /** 
4960 * 
50-  * @param  options {*} 
51-  * 
61+  * @param  options Object 
5262 * engineName - Engine to query, found in your App Search Dashboard 
5363 * hostIdentifier - Credential found in your App Search Dashboard 
54-  * initialState - This lets you set initial search parameters 
64+  * initialState - This lets you set initial search parameters, ex: 
65+  * `searchTerm: "test"` 
5566 * searchKey - Credential found in your App Search Dashboard 
56-  * searchOptions - A low level configuration which let's  you configure 
57-  * the options used on the Search API endpoint 
67+  * searchOptions - A low level configuration which lets  you configure 
68+  *   the options used on the Search API endpoint, ex: `result_fields`  
5869 */ 
5970 constructor ( { 
6071 engineName, 
@@ -76,10 +87,11 @@ export default class AppSearchDriver {
7687 this . URLManager . onURLStateChange ( urlState  =>  { 
7788 this . _updateSearchResults ( {  ...DEFAULT_STATE ,  ...urlState  } ,  true ) ; 
7889 } ) ; 
79-  // We filter these here, because the only state that should be allowed 
80-  // to be passed in, is search parameter state. Results, etc, should not 
81-  // be allowed to be passed in, that should be generated based on the 
82-  // provided search parameters. 
90+ 
91+  // We filter these here to disallow anything other than valid search 
92+  // parameters to be passed in initial state, or url state. `results`, etc, 
93+  // should not be allowed to be passed in, that should be generated based on 
94+  // the results of the query 
8395 const  searchParameters  =  filterSearchParameters ( { 
8496 ...this . state , 
8597 ...initialState , 
@@ -88,15 +100,15 @@ export default class AppSearchDriver {
88100
89101 // Initialize the state without calling _setState, because we don't 
90102 // want to trigger an update callback, we're just initializing the state 
91-  // to the correct default values.  
103+  // to the correct default values for the initial UI render  
92104 this . state  =  { 
93105 ...this . state , 
94106 ...searchParameters 
95107 } ; 
96108
97-  // We'll trigger an initial search if initial parameters contains  
109+  // We'll trigger an initial search if initial parameters contain  
98110 // a search term or filters, otherwise, we'll just save their selections 
99-  // in state as defaults . 
111+  // in state as initial values . 
100112 if  ( searchParameters . searchTerm  ||  searchParameters . filters . length  >  0 )  { 
101113 this . _updateSearchResults ( searchParameters ) ; 
102114 } 
@@ -310,6 +322,13 @@ export default class AppSearchDriver {
310322 } ) ; 
311323 } ; 
312324
325+  /** 
326+  * Set the current page 
327+  * 
328+  * Will trigger new search 
329+  * 
330+  * @param  current Integer 
331+  */ 
313332 setCurrent  =  current  =>  { 
314333 const  { 
315334 filters, 
0 commit comments