Skip to content

Instantly share code, notes, and snippets.

@isavch
Last active December 14, 2017 16:52
Show Gist options
  • Select an option

  • Save isavch/2512b994f39e632db945851208887734 to your computer and use it in GitHub Desktop.

Select an option

Save isavch/2512b994f39e632db945851208887734 to your computer and use it in GitHub Desktop.
Read cases
  1. Collection GET /wp/v2/posts Response [{id: 1, name: 'post'}, {id: 2, name: 'post2'}]

  2. Signle entity GET /wp/v2/posts/1 Response {id: 1, name: 'test'}

  3. Object collection GET /wp/v2/taxonomies Response { testA: { name: 'test a' }, testB: {name: 'test b'}, testC: { name: 'test c' }}

How will look store for different actions, READ, READ_FAIL, READ_SUCCESS ? Please note we should be able to handle routes like this statging/test/posts/revision/1. For complex routes it will be hard to distinguish where to put entities or data

So my understanding it would be easier to have smt like this in store

First case:

  • Requested
        posts: {
          status: 'requested'
        }
  • Fail
        posts: {
          status: 'fail',
          http: 401
        }
    
    
  • Success
        posts: {
          1: { id: 1, name: 'post'},
          2: { id: 2, name: 'post2'}
        }
    
    

Second case:

  • Requested
       posts: {
          1: {
             status: 'requested'
          }
       }
    
    
  • Fail
       posts: {
          1: {
             status: 'failed',
             http: 500
          }
       }
    
    
  • Success
       posts: {
          1: {
             id: 1,
             name: 'test'
          }
       }
    
    

Third case

  • Requested
    taxonomies: {
       status: 'requested'
    }
    
    
  • Fail
     taxonomies: {
        status: 'fail',
        http: 500
     }
  • Success
     taxonomies: {
        testA: { name: 'test a' },
        testB: { name: 'test b' },
        testC: { name: 'test c' }
     }
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment