Click here to Skip to main content
15,878,959 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am building an application that closely resembles Google keep. The problem lies in the following scenario.(realtime sync)

Consider a user visits my website on 2 devices i.e laptop and desktop.
When he edits/adds/deletes any new Note then the other device should sync up immediately.
My backend is a .NET Web API project and front end is going to be a react.js project.

So I thought the following ways to do it.
1. SignalR basically used for Real time messaging, where it notifies any changes to my frontend.

2. Worker service, consider as soon as Login internally I will be calling worker service that will send a response as soon as there is a change in my database. A basic sceanario would be something like the following:

Step 1. User logs in using his/her account.
Step 2. As soon as I Login on other devices or the same device a worker service starts that keeps listening for any changes in my database.
Step 2. User presses "+" button to create a new note on first device.
Step 3. React frontend makes a call to My backend(Create API)
Step 4. React frontend makes use of UseEffect for the response and updates the UI.
Step 5. As soon 1st device makes a call for create API there is a change and then the second device gets the updated data.

there are 2 questions,
1.Is SignalR is a better way to do this? I might not need SignalR for other things.
While on the other hand, worker service might just suit a small project like mine? I don't know if its the right use case for me to use Worker service.

2. Can frontend be constantly be polling for info on any change in the database. Does useEffect work in the right context here?

Thanks

What I have tried:

Researched on worker service and SignalR but confused to decide which one to choose in my scenario.
Posted
Comments
[no name] 3-Sep-20 10:07am    
What's the point of syncing an unattended device? Let the device sync itself when it is activated. Picture thousands of unattended devices syncing pointlessly.
Member 14929601 3-Sep-20 10:28am    
Thanks for your input, but I was just exploring the idea :) of syncing in real time to learn more about it in my app. If I may ask, the idea of syncing an unattended device holds true for google keep as well, isn't it? or are they doing something different? Also, I happened to notice it seems like the view refreshes itself after some seconds and there is also a refresh button provided to refresh the view.
[no name] 3-Sep-20 10:58am    
You're only thinking of the one case: someone staring at a screen waiting for an update. Rarely happens. They hit refresh even if it's not needed or have it on some polling interval. The idea of constantly "pushing" data, even when not asked for, is "inefficient". And Google is not paying for the bandwidth "you" use.
Member 14929601 3-Sep-20 11:49am    
Thanks, I get your point. I really wished they paid for my bandwidth :D
[no name] 3-Sep-20 13:02pm    
Maybe what you really need is "roaming data". I have a UWP app, and it has "roaming data" (settings). I plan to have "roaming files" (user data). It's all handled by Windows 10.

https://docs.microsoft.com/en-us/windows/uwp/design/app-settings/store-and-retrieve-app-data

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900