Skip to content

Commit e1d9c34

Browse files
committed
[add] Documentation
1 parent 82f569d commit e1d9c34

File tree

3 files changed

+43
-9
lines changed

3 files changed

+43
-9
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
### 4.0.0
4+
5+
- Added concept of plugins. Plugins provide a way to layer on
6+
additional functionality. This has specifically been added so that
7+
environment specific behavior may be added to an app.
8+
- Added `Microcosm::start`. Calling `start()` will bootstrap initial
9+
state, run all plugins, then execute a callback.
10+
311
### 3.3.0
412

513
- `mapBy` internal function now accepts an initial value

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,18 @@ app.ignore(callback)
290290
app.pump()
291291
```
292292

293+
## Booting things up
294+
295+
`Microcosm::start` begins an application. This will setup initial
296+
state, run plugins, then execute a callback:
297+
298+
```
299+
let app = new Microcosm()
300+
301+
app.start(function() {
302+
// Now do something
303+
})
304+
293305
## Additional Notes
294306
295307
The philosophy behind change management is described very well in the

docs/microcosm.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
1. [Overview](#overview)
44
2. [API](#api)
55
3. [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
112114
let app = new Microcosm()
@@ -120,3 +122,15 @@ app.ignore(callback)
120122
// Force an emission
121123
app.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

Comments
 (0)