I'm working on a mobile web app, where it is important to be able to continue working in offline mode if the connection is dropped, and have the data be sent whenever the connection is back up.
I'm experimenting with saving the object to LocalStorage on the error event, and deleting it from LocalStorage on the sync event. That seems to work fine, but where should I load it?
So far, I have overloaded Collection.fetch, to merge in the LocalStorage models and re-save them, but it feels kind of wonky.
Should I periodically try to re-sync the models until it succeeds?
The implementation:
https://gist.github.com/geon/7890291
Related
I am working on a project that shows live currency prices. I have to refresh the pricing data on the page dynamically. In this project I am using Django and SQL server. I could not figure out how to make it work using triggers and AJAX because AJAX needs an event to run like a user event or timer (that very bad for performance). Further, triggers can not be processed by Django. Is there a way to do it? Thank you for your help.
I'm wondering how does whatsappweb deliver updates?
Do you ever notice a left green card appearing sometimes and asking you to click in a link to refresh page and run the new whatsappweb fresh code updated.
I'm almost sure they use webpack, service workers etc.
Chances are that you already had cache problems using webpack where even refreshing page it remains cached.
So how does whatsappweb solved this issue with a single refresh link?
They use a service worker, if the service worker gets updated, they trigger something in the react app, is easy to do it.
serviceWorker.register({ onUpdate: () => {console.log('new service worker')}});
just dispatch something instead of the console.log
Webpack is a building tool and isn't involved anywhere on a live site. While it offers Hot Module Reload for the development server you will not get it on the production version.
Unlike traditional desktop applications, delivering updates for websites is as straightforward as updating the files on your server (and invalidating any browser caches). You don't need to notify the user to download something, a simple refresh will get the new pages.
If you really want instantaneous updates (without waiting for the user to refresh the page) you can create some sort of WebSocket communication which when a message is received triggers a browser refresh. Nothing special and no deployment mechanisms involved.
I'm working on project with Vue and laravel. In each and ever components have more than one http requests when page is mounting, it's slowing things down and sometimes returns 500 error. So i thought if the data is loaded and store in Vuex store and return when page load it'll be effective, but if the data inside the database changing while navigate through pages, data will not change re actively in pages. So is there a way to detect that change using javascript listners. Any help ?
You should look into https://laravel.com/docs/5.6/broadcasting Basically once your backend code does the change to the DB you will need to broadcast that change to the front end.
I have a list of transactions that are generated in seconds, I am using a wrapper to get these transactions so I made a rest api to get the transactions according to the no. But in the mean time the transaction will get generated more so how do I show the recent on as they generate continuously .
I want to create a Block Explorer on the private Ethereum blockchain using node.js as backend and angular.js as frontend.
You could use here Websockets.
For example Socket.io - https://github.com/socketio/socket.io
Here is Socket.io compoenent for Angular: https://github.com/btford/angular-socket-io
So when your transactions are generated, you will send Push message to client, and client will update it's transaction list.
Possibly the most common approach here, id you have control of contract mods, is to include event emitters for every important state change. This exposes your contract transactions in a detailed (even indexable) and inexpensive way.
On the client, you can use event watchers. This are easily configured with AngularJS. When events arrive, they invoke callbacks. You can do what you need to support the UI or offchain storage in the callback.
For example, you can append a row to an array in to Angular's view model. Angular does a good jub of updating the view when the data in the model as changed. So, a live updated display of transaction events as they arrive is quite feasible and not especially difficult.
Hope it helps.
Here is a problem that I am working on:
There is a view and it has a collection. I want to update the UI when the user interaction results in a model being added to the collection. The UI update should be instantaneous. If the web app is open in multiple browser tabs or windows then the view should get updated in all the tabs.
Possible Solution: Use localStorage for caching the data in the browser. Sync with the local server immediately and perform remote sync in the background. Bind UI updates with updates to the localStorage. There are plugins like Backbone.LocalStorage and Backbone.DualStorage. I went through their source code and these plugins do not take care of conflict resolution with server updates i.e. before syncing the data with the localStorage they donot check if the data was synced with the remote server.
Can anyone help me with this? Links to github repos, stackoverflow discussions are welcome.