Skip to content

Instantly share code, notes, and snippets.

View mark-kawakami-zefr's full-sized avatar

Mark Kawakami mark-kawakami-zefr

View GitHub Profile

Good API:

  1. Fast
  2. Good match of data required to data returned: In other words, API responses contain enough data to meet the needs of the app, and very little extraneous
  3. Response shapes:
    • Nesting is limited
    • Data needs little manual normalization on client side
  4. Useful, ideally machine-parsable, errors
  5. Consistent representation: Entities/objects should be consistent in terms of naming, data types, structure, etc. from endpoint to endpoint

Good API:

  1. Fast
  2. Good match of data required to data returned: In other words, API responses contain enough data to meet the needs of the app, and very little extraneous
  3. Response shapes:
    • Nesting is limited
    • Data needs little manual normalization on client side
  4. Useful, ideally machine-parsable, errors
  5. Consistent representation: Entities/objects should be consistent in terms of naming, data types, structure, etc. from endpoint to endpoint

Good API:

  1. Fast
  2. Good match of data required to data returned: In other words, API responses contain enough data to meet the needs of the app, and very little extraneous
  3. Response shapes:
    • Nesting is limited
    • Data needs little manual normalization on client side
  4. Useful, ideally machine-parsable, errors
  5. Consistent representation: Entities/objects should be consistent in terms of naming, data types, structure, etc. from endpoint to endpoint
@mark-kawakami-zefr
mark-kawakami-zefr / reducer.js
Last active December 18, 2017 21:28
Combing actions with recursive reducers (Reducer Inception)
/*
In this example, imagine a modal for editing a record. The typical use case is that the user edits a record
in a modal and hits a save button. The save button should dispatch the action(s) to update the record and close the modal.
Let's assume we sometimes want to close the modal without updating the record (because the user pressed the "cancel" button),
and also that sometimes we want to update the record without closing the modal (maybe because we've got some edits that
don't even require the modal to be open in the first place). That means we want to have an action just for closing, and
another just for updating.
That would look like this: