Skip to content

Instantly share code, notes, and snippets.

@aackerman
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save aackerman/767622f82f1bf244b1e0 to your computer and use it in GitHub Desktop.

Select an option

Save aackerman/767622f82f1bf244b1e0 to your computer and use it in GitHub Desktop.
Flux gotchas
* Dispatching undefined actions types
* FIX: Add a method on the dispatcher to check for undefined action types and throw errors when this happens
* Attempting to receive a dispatch with an undefined action type
* ex. switch on an undefined action type key
* FIX: Check action type for undefined and throw an error
* Fallthrough switch case in dispatcher callback
* FIX: Linting
* FIX: Use a method instead of a switch statement
* Naming actions
* FIX: Attempt to use a record type, singular and plural, and FIND, DESTROY, CREATE, UPDATE VERBS
* ex. RECORD_TYPE_FIND, RECORD_TYPE_DESTROY
* Lots of objects, Model, ActionCreator, Store per record type.
* FIX: combine action creators and stores in ways that make sense
* Where are models created in a Flux pattern?
* Models are only created in Actions and in tests
* Actions use a defined interface, to translate inputs into raw API requests and translate responses into models
* If in-memory only models are necessary, create a model factory with an interface that can be used synchronously without action->dispatch->store, it's unlikely that an unpersisted model should be in a store.
* Abstract the complexity of an API, models should not necessarily map 1:1 to an API because the API is likely to change and it is important to reduce coupling.
* Integration tests are important specifically for the Action->Dispatcher->Store part of dataflow.
* Errors when dispatching
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment