How can Meteor applications work offline?

This is useful if:

  • the server is down and the client cannot connect to the synchronization in real time
  • no internet connection
  • the user does not want to enter the network, but wants to work with the application;
+49
meteor offline
Apr 13 '12 at 5:18
source share
4 answers

Yes! This has already been implemented in Meteor, for the most part.

If the connection to the server is lost, the client can still work locally. The database record will be successful on the client and will instantly appear on the screen. Once the connection is restored, Meteor will resubmit all pending method requests to the server and update the client display with the results from the server. This is the result of latency compensation because it is disabled because the server is very slow.

Customers can track the reactive output of "Meteor.status ()" to see the status of the current connection. For example, you can use Meteor.status to launch a pop-up window with a reconnect timer and a "connect now" button, for example gmail.

EDIT: Of course, Meteor is not magical. If you click "reload" or go from the page, etc., while offline you will lose the Meteor session and will not be able to start again until you restore the network. This is true for all offline web applications, so this should not come as a surprise to users of your application.

+55
Apr 13 2018-12-12T00:
source share

There are several other options that can solve the problem "if your tab closes or you are rebooting." I have not tried them yet, but I look interesting.

https://github.com/awwx/meteor-offline-data :

Meteorite offline data

Home of the Meteor offline data project implementing the “Offline Collection” that wraps Meteor.Collection:

Data from the server is stored permanently in the browser database, making it available for the application, even if the application is launched offline.

Changes made by the user are also saved in the browser database, saving them if the browser is closed and reopened. The next time the application goes online, the changes are sent to the server.

Updates are distributed differently between browsers that are open on the same application, even offline.

and https://github.com/GroundMeteor/Meteor-GroundDB :

Features:

Light footprint

Extensive browser support for Chrome, Safari, Firefox, and Internet Explorer 9 Return to normal Meteor.Collection if there is no localstorage. changes in collections. Resume methods. window tabs Support SmartCollection Support for offline client databases Uses EJSON.minify and EJSON.maxify to compress data in localstorage In the future, there will be a custom conflict handler on the server side

+10
May 13 '14 at 9:37
source share

Bottom of the line:

1) The browser can completely save the actual session (every time the application requests it because it received changes. For such an application every 10 seconds is not enough, we need all the events). Can we program it in Firefox? (But for this you need to save everything (HTML, JS, MinoMongoDB, etc. Only for one change!)

2) Or we have a full meteorite stack on the client side, which takes care of local things (our own local application), but somehow transfers its CRUD operations to another online application on another tab or browser instance. (This second application will be served by a real remote server). The problem is whether such 2 applications can communicate. I suppose browsers would ban it for security reasons)

Another creative idea might be: Activate oplog on the client stack. Then, each back-online and constantly, when it is online, the actual client oplog can be exported / imported to the main application (this is another oplog log).

3) If we cannot send a call () request from the full meteor client stack to another meteorite stack on the server. (Is this possible? Are there any rules regarding domain name restrictions in the meteor)

But it does not fix the possibility of having a full stack of meteors on the tablet (I do not know what is possible)

0
Feb 05 '15 at 17:12
source share

I am not an expert, but imagine a solution:

Not on a tablet / cell (not sure that we can install a meteorite stack on such a device), but on the desktop the user needs offline availability, such as a point of sale, some transaction logging, limited or not updated -date list of products, prices and inventory etc. (Transactions using stocks that are not physically local must be “confirmed (offline)” (Places in which this stock can be sold, even if it is already reserved in a stand-alone order that they are not aware of, because they or another user is not connected to the network, especially if the user has a reserve offline)

In addition, some functions can only be used online (using another Meteor web application)

Of course, not all parts of the application can be used offline: creating confidential records, some transactions, searching, requiring a complete collection, etc. Functions offline will work through the machine’s local web server with a working local full stack Meteor is already installed.

Oplog synchronizes these offline databases with a mirror collection on a centralized server, one specific database per user, so not all big data is available offline on the user machine. The idea is to keep some features available. Otherwise, we could have only one database for offline transactions of all users, but oplog will synchronize all these transactions in all offline user databases. We could POST and clear these entries as soon as possible, but not good for privacy. Best of all, the client autonomous database is mirrored on a centralized server - it will include only records created by this user, or information that the user may require, therefore, one specific database for the user.

A central server-side function will regularly check and POST these records for a larger number of all users, including a centralized database.

Easy way: all transactions made with a local offline meteorite application that will send transactions to the web service when they are available. (Thus, users do not need to manage two applications by going back and forth.)

We could use the concept of two account numbers: Sales invoice number: generated during the transaction (document ID?)

Sequence number of the invoice: for accounting purposes, generated later (when online and for documents from 15 to 20 seconds. Old. We know for sure all new invoices created for this period)

The idea here is to have a local meteorite stack receiving a local resistance car, Oplog synchronization with centralized resistance (if we do not send asynchrone webservice calls to post transactions online, but we lose auto sinc with a larger database)

(In the end, it may be better to have 2 applications: on a local, one central service and a way to allow these 2 conversations together or an online and offline application with a convenient way to direct the user to use the online version in priority and offline mode, if it is disabled)

It would be nice if a community of more knowledgeable people evaluates and documents the workflow. I have not used Meteor yet, while still in the main learning process.

Thank,

Mark

-one
Jan 31 '15 at 19:45
source share



All Articles