Load data to service when it turns to online - javascript

I am able to add data to indexeddb when it is offline using service-worker in PWA but want to add the same data to service when it comes online(means i want to store the data into database by calling service). How to achieve this?

Your question is not very clear. There are two interpretations of it and I'll try to answer for both.
Question - You want to use service worker in both offline and online cases.
Answer - There shouldn't be any problem in doing it the same way.
Question - How can you send the data to server, which was saved in IndexedDB when the app was offline.
Answer - You want to use Background Sync.
If there's any different requirement which you may have, please feel free to ask but try to ask it a bit clearly. Hope this helps!

Related

Storing questions and user answers in localstorage to reduce database and server load

I am making a quiz application. I am wondering if storing questions and user's answer to localstorage then submit once completed is good and effective way to reduce database / server load if let say I have 2,000 concurrent users? Or are there any alternative way?
PS.
I'm using a shared hosting.
If you wanna store a few questions sure.
But generally I would recommend using the IndexedDB instead.
IndexedDB on MDN
The honorable gentlemen suggested load testing, but for such a small application that seems overkill, probably takes more time to setup if you never used one than it's worth.
I would also suggest using a cache (eg. Redis) on the server side.

Share data without database

I have this web application that gets and displays data from SAP, but i need a way (maybe a JSON file?) to share some data between different users, with the possibility to modify these same data for each user (even at the same time), without a database. There will be really small data and few users, and what i would write is simple data that tells me who is online in that moment. How can i do? I'd like to know if exist an easy solution to share these really small and simple data. I'm using React with no back, because i'm taking all the data i need from SAP. Clearly, i'm a beginner. All advice is welcome.
If you talking about some prototype like MVPs, I think JSON files would be best.
However, consider to work also that you can work with Local Storage.
You could use LocalStorage, SessionStorage or IndexedDB, but the last option is an in-browser database. Maybe LocalStorage is your solution.

Jsfiddle, codepen,Jsbin like front end - Javascript

I've created HTML/CSS/JS playground some well known playground like Jsfiddle, codepen,Jsbin etc.
i would like to know about, "how to save and load the workaround when the user logging in again?" i want user to save their workaround and let them resume from where they stopped.
what approach/idea/possible ways available for this?
do i need to know session/local storage very well?, if not, kindly share your experience. if possible pls share tutorial/example snippets or any other work around.
Note: before asking questions here, i have searched solution as much as i can. but not able to uderstand.
many thanks for any help.
Here are the options that you have:
If you want the data to be persistent for users then you need to implement user login and store their data in your database on the backend. That way they will still have it if they log in on a different browser or device.
If you use local storage then it will be saved only for that browser and and every time the user changes the browser the data will be lost.
If you don't want to implement your own backend then you can use something like Firebase or other solutions: see noBackend for more options and more info.
Another option is to use a solution described on StaticApps or unhosted which are very interesting ways to avoid using any backend logic in your apps but still keep some persistent state.

Is it possible to retrieve data from parse.com using objective-c and show it in website?

I have an iOS app in which I use parse.com as backend service. Now, I hired someone to do a website interface using HTML and CSS. I want to share the same data between iOS app and website, I know parse.com offers me a few ways to do this, including creating a javaScriptapplication. The problem is, my programmer doesn't have any experience in JavaScript, nor do I.
My question is: Is it possible to use what I have (objective-c, xcode) as far as retrieving data from parse.com and showing on website? Even if I need to code something new, is it possible to use objective-c together with HTML and CSS?
Thanks.
Parse has several APIs, one of which is REST. Your web developer should use the REST API to get data from Parse
https://www.parse.com/docs/rest
If there is will there is way, but you'll be making something really specific to your use and will be non standard and will be immediately hard to maintain, I recommend that you hire another developer and do things properly using the technologies given to you by parse !. if the cost will be high now I can promise you it'll be much higher if you went the path you're going to now.
So my answer is:
Yes, everything is possible and no, don't do it ! :)
Edit: Added an example to a possible way to do it to actually answer OP's question.
Example case:
1-Create a simple Mac Application in Xcode that fetches data exactly like you do it on iOS, and store the needed data into a database of your choice on your server
2-You now have access to the data you needed from parse, but on a local mirror. you will need some tool to fetch that data though, I recommend a simple PHP script.
Note that this will require an OSX server to always be running to fetch that data, you'll also need of find a way to fetch data on demand when a user needs it Vs. polling at specified intervals, this will hardly scale and will be costly as I said.

Storing user data for free

I will make a website where users log in to see the site's info organized in a way which is specific to each user, depending on the settings which they can set/save while logged in. But they won't be adding content or uploading anything. So I guess, it won't be a lot of data - just a couple lines of text for each user.
So, to start out, I'd like to use something free to store that user data. Dropbox or Google docs, my own compter.... I dont know.
And then later, when I get enough users to make the investment worthwhile, pay for a more legitimate solution.
My question is, in the meantime, what is the best way to store that user data? Should I use javascript and Google docs API to read/write to a spreadsheet?
What is going to be most convenient when my user base has grown enough and it comes time to move all that over to a larger system?
And are there any other concerns I should be thinking about?
Look into using a lightweight DBMS like MySQL. If you want, you can serve it locally using your computer, but don't expect it to handle a lot of traffic. It'd be better to find an old computer and use that as a server.
What is your hosting solution? Many include free mySQL databases which should be enough.
I would suggest using sqlite3 or something for a database setup. They can be very small files and easily manageable. In the long-run sqlite3 isn't a great choice. You would want to move to a heftier database assuming you rake in a lot of users.

Categories

Resources