0

Is there a way to send an event with js to trigger a ui update (refresh?) off database insertion?

I'm building a web app to handle a queuing system for my school. I've gotten the major systems in place and working. Tutors are reading off a active q array in a nosql databse (couchDB). When students q, a new object is created there. The problem is, the Tutor has to manually refresh the page to see any new objects that have been added after they've loaded the page.

I know Redux would solve this problem, but the rest of my team is not keen to switch. Mobx is my state manager, and the app is built in react. So is there a way to trigger a specific Tutor refresh off a insertion into the db?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
NLand
  • 19
  • 3
  • Yes, you can create a database trigger that could insert a row into a table with info on what to refresh that you could constantly poll on a delayed loop and if a relevant row exists, Delete it and refresh – iJamesPHP2 Feb 29 '20 at 03:42
  • Your problem isn't one of mobx vs. redux... any state machine would work. Research http polling, http2 push, and websockets. Those are the three best options for how to automatically send data from a backend to a frontend app. – JoshuaCWebDeveloper Feb 29 '20 at 03:44
  • Awesome, will look put on the research gloves, thanks – NLand Feb 29 '20 at 03:51

1 Answers1

0

Turns out there is a built in API method in pouchDB for just this. https://pouchdb.com/api.html#changes

NLand
  • 19
  • 3