331 . [ Overview] ( #overview )
442 . [ API] ( #api )
553 . [ Listening to Changes] ( #listening-to-changes )
6+ 4 . [ Running an instance] ( #running-an-instance )
67
78## Overview
89
@@ -68,13 +69,14 @@ class MyApp extends Microcosm {
6869 // resulting callbacks into a change set. If state changes, it
6970 // will trigger a change event after assigning the new state
7071 }
71- addStore (... stores ) {
72- // For each store, folds over a default interface and then assigns
72+ addStore (store ) {
73+ // Folds over a default interface and then assigns
7374 // the result of `store.getInitialState` to the associated key for
7475 // that store (defined by store.toString())
75- //
76- // Finally, it will concatenate the processed stores into the
77- // list of known stores.
76+ }
77+ addPlugin (plugin ) {
78+ // Verifies required api and adds available plugin. This will be
79+ // called on app.start()
7880 }
7981 serialize (state ) {
8082 // Transforms the internal state of a microcosm into a digestable
@@ -100,13 +102,13 @@ class MyApp extends Microcosm {
100102 toJSON () {
101103 // A default implementation of serialization. Just returns `this.serialize()`
102104 }
105+ start (callback ) {
106+ // Setup initial state, run plugins, then execute callback
107+ }
103108}
104109```
105110
106- ## Listening to Changes
107-
108- All microcosms inherit from ` src/Heartbeat.js ` . Heartbeat is an event
109- emitter with a single event:
111+ ## Listening to changes
110112
111113``` javascript
112114let app = new Microcosm ()
@@ -120,3 +122,15 @@ app.ignore(callback)
120122// Force an emission
121123app .pump ()
122124```
125+
126+ ## Running an instance
127+
128+ ` Microcosm::start ` begins an application. This will setup initial
129+ state, run plugins, then execute a callback:
130+
131+ ```
132+ let app = new Microcosm()
133+
134+ app.start(function() {
135+ // Now do something
136+ })
0 commit comments