Giter VIP home page Giter VIP logo

ditto-js-quickstart's Introduction

Ditto Color List App - Quick Start

This is a basic Ditto quick start example in javascript. To goal is to get you syncing basic data with Ditto as fast as possible!

Getting Started

  1. Clone this repo - git clone https://github.com/skylerjokiel/ditto-js-quickstart.git
  2. Navigate to the new folder - cd ditto-js-quickstart
  3. Install dependencies - npm install
  4. Open ./src/app.js and update the appID and token line 18 & 19 respectively with your Ditto App specific info found in the Ditto Portal. For more information on how to find these see: https://docs.ditto.live/get-started/sync-credentials
    ditto = new Ditto({
    type: "onlinePlayground",
    appID: "YOUR_APP_ID",
    token: "YOUR_PLAYGROUND_TOKEN",
    });
  5. Start the app from your terminal - npm start
  6. Launch a browser window http://localhost:1234

Collaboration

To see real-time collaboration using Ditto

  1. Open another tab and automatically see them syncing changes
  2. Open the DQL Editor in the Ditto Portal to explore the data https://portal.ditto.live/dql-editor/YOUR-APP-ID

ℹī¸ Ditto's web application only support real-time collaboration through the Ditto cloud (Big Peer) and not direct peer-to-peer collaboration. This is due to limitation in system access that browsers provide.

App Overview

The Generate Color button will add a new color document to our colors collection and display in a list along side. Deleting a color will mark the isDeleted flag to true and it will be filtered from the view. alt text

Data Modeling

Documents are stored in the colors collection.

Document in the colors collection have the following schema:

{
    _id: string // uuid auto generated by Ditto
    color: string // hex value
    isDeleted: boolean // denotes if the color was deleted (default false)
}

Troubleshooting

If your app is working but not syncing data these are common errors you might find in the console.

Invalid App ID

Uncaught (in promise) Error: Provided App ID was not a valid UUID at dittoIdentityConfigMakeOnlinePlayground (ditto.es6.js:1:78162) at ditto.es6.js:1:194788 at new Ditto (ditto.es6.js:1:195096) at HTMLDocument. (app.js:14:11)

If you see the above message it means that your provided Ditto AppID was invalid. Make sure to follow step 4 in the Getting Started section.

Invalid Token

POST https://YOUR-APP-ID.cloud.ditto.live/_ditto/auth/login 401 (Unauthorized)

If you see the above message it means that your App ID is valid but the token your provided is invalid. Double check to make sure you have the correct App ID and Playground Token from the Ditto Portal.

ditto-js-quickstart's People

Contributors

skylerjokiel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.