Coder Social home page Coder Social logo

mark-down-app's Introduction

Features to add with localStorage:

  1. Sync notes with localStorage : App.jsx

    DOCS

  2. Add note summary titles : Sidebar.jsx

  3. Move modified notes to the top of the list : App.jsx

  4. delete notes : App.jsx

Adding Firebase to the project

- Setup firebase config and initialise the app
- Create a instance of database and
- setup a collection

Use firestore function - onSnapshot to add a listner for database to sync with local states
Firestore databse overwrite ID for each document

onSnapshot - listener

addDoc - create a document with a parameters : instance of collection, new document {promise}

doc - gets a specific document, parameters : instance of database, collection name, document id {return document ref}

deleteDoc - deletes a document in the firestore database, parameter : document ref {promise}

setDoc - updates a document in the firestore database, parameter: document ref, {updated object}, {merge : true/false} either you can update/overwrite the complete document or merge it with old document {promise}

Debouncing

Problem: currently we are making request to firestore on every single keystroke, therefore need to reduce request for read and write from firestore

Solution: Debouncing
- delay the request for specified amount of time (let 500ms).
- if another request happens within the specified delay time, then cancel the prev request and set up a new delay for the new request.

Implementation:
- remove connection of updating database between editor and app - for making request to firestore
- setup a useState state of keeping track of body of note
- using setTimeout with useEffect to handle debouncing

mark-down-app's People

Contributors

puru-soni 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.