This code was made for an article I wrote about how to develop offline first applications using Couchbase Sync Gateway.
While studying react-redux, something that I really liked is the Async Actions pattern where you have:
{ type: 'FECH_POSTS_REQUEST' }
{ type: 'FECH_POSTS_FAILURE', error: 'Oops' }
{ type: 'FECH_POSTS_SUCCESS', response: { ... } }
This pattern provides a very good user experience because you actually render the page based on the current status of the app. I'm trying to achieve the same results but for offline first applications using Couchbase.
To create a PoF, I develop this project and everytime you save a document with:
{
"action": "person_request"
}
It Couchbase Sync Gateway call Flask which will schedule a Task that will retrieve a random person(20% chances of failing) from SWAPI.
- Couchbase Sync Gateway
- Flask API
- Celery + Redis
docker-compose up
First clone this repo to see all the changes being made in real time and then just add a document with curl.
curl -H "Content-Type: application/json" -X POST -d '{"action":"person_request"}' http://localhost:4984/db/