Skip to content
This repository has been archived by the owner on Dec 19, 2020. It is now read-only.

Example of developing an API less using Couchbase Sync Gateway

Notifications You must be signed in to change notification settings

rafaelugolini/syncgateway_offline_first_example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Offline First Apps with Couchbase Sync Gateway

This code was made for an article I wrote about how to develop offline first applications using Couchbase Sync Gateway.

Idea

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.

Proof of Concept

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

alt

Running

docker-compose up

Testing

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/

About

Example of developing an API less using Couchbase Sync Gateway

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages