New package - jam:offline - An easy way to give your Meteor app offline capabilities

Quick update: I found a server reconciliation bug that has been fixed in v0.3.3 so you’ll want to update to the latest. You may have run into it if you decided to keep additional collections for offline use after you initially set things up. :slight_smile:

I’ve just released v0.4.0 which includes support for using an archive mechanism instead of soft deletes when reconciling with the server. :tada:

See the auto syncing section of the readme for more info.

4 Likes

Hi.
I have started integrating the jam:offline package for my web app.
So I have a web app that is packaged into a desktop app by an electron-builder setup. I want the desktop app to implement both online and offline data sync. My desktop app is configured such that the data doesnt directly sync to the mongoDB database. It is connected to the web app host URL and via this route, the data sync occurs and hence am not passing the MONGO_URL in the desktop app and the sync occurs via DDP protocol
But for the offline support, is the MONGO_URL required? They say the MONGO_URL is required. Is that true?
Also, in the web app, is it fine to configure the web app to function without the indexedDB and just use the cloud mongo server.
I’m new to meteor packages and appreciate some guidance on this

jam:offline uses minimongo to store data in indexeddb. So as long as your data makes into minimongo on your desktop app, you should be good to go.

If I understand correctly, you want to have offline capabilities for your desktop app but not your web app? If so, if you have some flag or way of programmatically determining the environment in which the code is running, you could put Offline.configure({ … }) inside it. I haven’t used electron-builder setup so I’m not sure what’s available but hopefully this can point you in the right direction. If someone is using electron and reading this, maybe they can provide more insight.

1 Like

@jam
Thanks for your input. Can you please answer this question as well:
I have meteor 2.16 and got this log while trying to check if jam:offline’s Offline API is available on the client side of my web app .
I got this message:
[jam:offline] Offline API is NOT available on the web on the client.

Is jam:offline compatiblw with meteor 2.16?
This is the .meteor/package file:

Meteor packages used by this project, one per line.

Check this file (and the other files in this directory) into your repository.

‘meteor add’ and ‘meteor remove’ will edit this file for you,

but you can also edit it by hand.

less@3.0.2
iron:router
underscore@1.0.10
sacha:spin
jonblum:jquery-cropper
twbs:bootstrap
semantic:ui-css
aldeed:autoform@5.4.0
aldeed:autoform-bs-datetimepicker
tsega:bootstrap3-datetimepicker@=3.1.3_3
maazalik:highcharts
gquemart:meteor-reactive-fullcalendar
steeve:jquery-qrcode
jeremy:selectize
aldeed:simple-schema@=1.3.1
jeremy:geocomplete
mdg:geolocation
mrt:autojoin
reactive-var@1.0.11
aldeed:template-extension
momentjs:moment
aldeed:moment-timezone
percolate:synced-cron
service-configuration@1.0.11
matb33:collection-hooks@1.0.1
reywood:publish-composite
tmeasday:publish-counts
force-ssl@1.1.0
meteor-base@1.4.0
mobile-experience@1.0.5
mongo@1.8.0
blaze-html-templates@1.0.4
session@1.2.0
jquery@1.11.11
tracker@1.2.0
logging@1.1.20
reload@1.3.0
random@1.1.0
ejson@1.1.1
spacebars@1.0.12
check@1.3.1
standard-minifier-css@1.6.0
standard-minifier-js@2.6.0
shell-server@0.4.0
benjaminrh:jquery-cookie
ecmascript@0.14.0
dynamic-import@0.5.1
email
promise@0.11.2
mdg:meteor-apm-agent
accounts-oauth
useraccounts:bootstrap
accounts-password
useraccounts:iron-routing
stylus@=2.513.14
accounts-base
accounts-ui
oauth
oauth2
ostrio:files
alanning:roles@3.6.3
jam:offline
jam:method

Yes it is compatible with Meteor 2.16. I’m not sure where that message is coming from since the package doesn’t produce one like it. At this point, it’s probably best to open a github issue on the jam:offline repo with more info like screenshots or a minimal reproduction. Thanks!

Hello @jam as usual thank you for all the good things you keep providing to the community.

How does your package differ from GitHub - ccorcos/meteor-subs-cache: A Meteor package for caching subscriptions.? Is it in anyway inspired by it? Can both be used? What’s the difference here? Thanks!

For caching subscriptions, see jam:pub-sub. It’s meant to serve as a replacement for the package you linked. It

  1. should be more reliable
  2. has a much better DX
  3. provides a lot more than simply caching subscriptions though it can be used for only that

jam:offline provides offline capabilities to your app so its purpose is totally different.

Thankyou @jam . I added the jam:offline package in my web app using meteor add jam:offline command and then I could see the package being added in the .meteor/package file. But when I tried to import it using import { Offline } from ‘meteor/jam:offline’ statement, I am getting an error saying jam:offline is not defined. So I used this to define Offline object :
const Offline = Package[‘jam:offline’] && Package[‘jam:offline’].Offline;
I could see the object being initialized in the dev tools but the thing is, only these methods were available:
Package && Package[‘jam:offline’] && Package[‘jam:offline’].Offline
{config: {…}, configure: ƒ}
config: {filter: {…}, sort: {…}, limit: 100, keepAll: true, autoSync: true, …}
configure: options => {…}
[[Prototype]]: Object
and isSyncing and Collection.keep() are missing which is impacting the data sync for my application. 1) Can you please suggested where I might be going wrong?
2) Can you confirm if jam:offline version 0.4.1 is best suited for meteor 2.16?

@deepak28 are you by any chance trying to import Offline on the server?!

No im trying to import on the client side

Hmm not sure why it’d be saying it’s not defined. Have you tried a meteor reset? Maybe there’s a cache issue.

In general I would suggest making sure it’s the last package listed in your .meteor/package file. I would not recommend defining Offline yourself.