Skip to content

Redux-like message bus documentation #4

Description

@jdylanstewart

DISCLAMER: I have only been working with auto documentation for a few months now, so I might be missing something simple.

I realize this is WAY outside of the scope of things you are likely thinking about right now, but I thought I would leave it here as food for thought.

Documenting message bus architecture has been a challenge for me for a while now and after asking around a lot, have not really gotten a good solution for.

In Redux (or similar message bus architectures a la Socket.io, webworkers etc) there is a very cleanly defined actionTypes/actions/reducers format which presents documentation challenges.

Example:

actions.js

 export const ADD_TODO = 'ADD_TODO';
 
 export function addTodo(todo) {
   return ({
     type: ADD_TODO,
     todo: todo,
   });
 }

reducers.js

export default function todoReducers(state = initialState, action) {
  switch (action.type) {
    case ADD_TODO: {
      return state.push(action.todo);
    }
    default: {
      return state;
    }
  }
}

todoApp.js

import { createStore } from 'redux'
import addTodo from './actions';
import todoReducers from './reducers';

const store = createStore(todoReducers);

const todoItem = { msg: 'do yo thang' };

store.dispatch(addTodo(todoItem));

Now, in the mental model of the design, there is a very clear coupling of the actionType constant string, the action creator functions, and the associated reducer case in such a way as it would be beneficial to document them together (at least in a linked documentation way). However, it also makes sense to keep them in separate files for clarity reasons (I'll direct details of that to http://redux.js.org/docs/recipes/ReducingBoilerplate.html).

Again, I recognize this is likely outside the scope of what you are working on, but I think it represents a problem with auto documentation and associating spatially disparate pieces of documentation together that is at least worth a discussion.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions