git.fiddlerwoaroof.com
Browse code

Add some docs

Ed Langley authored on 21/06/2019 17:33:15
Showing 4 changed files
... ...
@@ -60,8 +60,8 @@ function* toplevel() {
60 60
     try {
61 61
       yield rootTask.toPromise();
62 62
     } catch (err) {
63
-      console.log("Error!");
64
-      yield put(recordError(err));
63
+      console.log("Error!", err);
64
+      yield put(recordError(err.toString()));
65 65
 
66 66
       const { type } = yield take([
67 67
         "co/fwoar/APP_RESTART",
... ...
@@ -14,9 +14,11 @@ const initialState = {
14 14
   error: null
15 15
 };
16 16
 
17
-export const rootReducer = (state = initialState, action) =>
17
+export const rootReducer = (state = initialState, action) => (
18
+  console.log(action),
18 19
   R.cond([
19 20
     [typeEquals(UPDATE_NAME), applyAction("name", state)],
20 21
     [typeEquals(UPDATE_IP), applyAction("ip", state)],
21 22
     [R.T, action => ({ ...state, error: errorReducer(state.error, action) })]
22
-  ])(action);
23
+  ])(action)
24
+);
... ...
@@ -5,13 +5,14 @@ import { action } from "./redux-utils";
5 5
 export const restart = () => ({
6 6
   type: "co/fwoar/APP_RESTART"
7 7
 });
8
-const RECORD_ERROR = "RECORD_ERROR";
8
+const RECORD_ERROR = "co/fwoar/RECORD_ERROR";
9 9
 export const recordError = action(RECORD_ERROR);
10 10
 
11 11
 export const errorReducer = (state = null, { type, data }) => {
12 12
   if (type === "co/fwoar/APP_RESTART") {
13 13
     return null;
14 14
   } else if (type === "co/fwoar/RECORD_ERROR") {
15
+    console.log("recording an error");
15 16
     return data;
16 17
   } else {
17 18
     return state;
... ...
@@ -7,14 +7,14 @@ export const Root = ({ name, updateName, ip, getIp, fail, error, restart }) => (
7 7
   <div>
8 8
     {error ? (
9 9
       <div>
10
-        {error}
11
-        <button onClick={restart}>Restart</button>
10
+        Received an error with message: {error} Get Ip won&apos;t work until
11
+        error resolved. <button onClick={restart}>Restart</button>
12 12
       </div>
13 13
     ) : null}
14 14
     <NameControl name={name} updateName={updateName} />
15 15
     <IpControl ip={ip} getIp={getIp} />
16
+    <p />
16 17
     <button onClick={fail}>Fail</button>
17
-    <button onClick={restart}>Restart</button>
18 18
   </div>
19 19
 );
20 20
 Root.propTypes = {