All Projects → mixmaxhq → meteor-smart-disconnect

mixmaxhq / meteor-smart-disconnect

Licence: MIT license
A Meteor package that disconnects your site in a smart manner.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to meteor-smart-disconnect

comical-jekyll-theme
A Configurable Webcomic Theme for Jekyll
Stars: ✭ 39 (-42.65%)
Mutual labels:  unsupported
ubiquitous-memory
new version? pull request.
Stars: ✭ 58 (-14.71%)
Mutual labels:  unsupported
minio
Minio Object Storage in Kubernetes, used by Deis Workflow.
Stars: ✭ 51 (-25%)
Mutual labels:  unsupported
bal-util
Utility functions for JavaScript and Node.js used and maintained by Benjamin Lupton
Stars: ✭ 13 (-80.88%)
Mutual labels:  unsupported
logger
In-memory log buffer used by Deis Workflow.
Stars: ✭ 17 (-75%)
Mutual labels:  unsupported
builder
Git server and application builder for Deis Workflow
Stars: ✭ 40 (-41.18%)
Mutual labels:  unsupported
dockerbuilder
Deis dockerbuilder builds your app from a Dockerfile inside a Kubernetes pod, used by Deis Workflow.
Stars: ✭ 17 (-75%)
Mutual labels:  unsupported
rigger
rigger is a tool to deploy Deis v1 on a variety of cloud providers.
Stars: ✭ 57 (-16.18%)
Mutual labels:  unsupported
CSScaffold
The original CSScaffold by Anthony Short... He deleted the original repository when he released the newer version.
Stars: ✭ 26 (-61.76%)
Mutual labels:  unsupported
Deis
Deis v1, the CoreOS and Docker PaaS: Your PaaS. Your Rules.
Stars: ✭ 6,107 (+8880.88%)
Mutual labels:  unsupported
docpad-skeleton-yui
A YUI Purecss 0.6.0 skeleton for DocPad.
Stars: ✭ 13 (-80.88%)
Mutual labels:  unsupported
Unsupported
Unsupported Zenphoto scripts [abandoned]
Stars: ✭ 18 (-73.53%)
Mutual labels:  unsupported
ArcGIS.PCL
Migrated to https://github.com/davetimmins/Anywhere.ArcGIS
Stars: ✭ 39 (-42.65%)
Mutual labels:  unsupported
simple-server
Use https://github.com/zeit/serve or `python -m SimpleHTTPServer 8000` instead
Stars: ✭ 33 (-51.47%)
Mutual labels:  unsupported
postgres
A PostgreSQL database used by Deis Workflow.
Stars: ✭ 37 (-45.59%)
Mutual labels:  unsupported
docpad-skeleton-nodechat
Node Chat, built using Socket.io, DocPad, Backbone.js and Twitter Bootstrap
Stars: ✭ 35 (-48.53%)
Mutual labels:  unsupported
docpad-plugin-inlinegui
Plugin that brings Web Write's Inline GUI/CMS to DocPad
Stars: ✭ 14 (-79.41%)
Mutual labels:  unsupported
cisco ios
Cisco IOS Catalyst module
Stars: ✭ 14 (-79.41%)
Mutual labels:  unsupported

Meteor Smart Disconnect

Meteor connections are expensive. That's why Meteor introduced Meteor.disconnect(). It allows you to disconnect the entire Meteor client from the server. Reconnecting is as easy as calling Meteor.reconnect().

So why keep the app connected if your user isn't interacting with your app? This simple package will disconnect your app when the user switches to another tab and leaves your app in the background. It will also debounce for 60 seconds so it doesn't disconnect and reconnect if the user is switching through tabs quickly.

Adding

Add this to your app with:

meteor add mixmax:smart-disconnect

Meteor Settings

You can change the time for which the user is away for before you disconnect. By default this value is 60 seconds, but you can set disconnectTimeSec in your Meteor settings file to a different value to change this. This value is in seconds and disconnectTimeSec should be a public value in your settings file.

If you are using the Iron Router package, you can stop the smart-disconnect from working on some of your routes by adding a disconnectVoids key into the public section of your settings file. It must be an array of route names such as:

"disconnectVoids" : ["Dashboard","Account","Profile"]

If you are not using the Iron Router package, you can stop the smart-disconnect from working on some of your routes by passing their pathname:

"disconnectVoids": ["/dashboard/account", "/dashboard/settings"]

Check Disconnect & Reconnect

You can test whether you are connected or disconnected by using Meteor's Tracker package:

import { Tracker } from 'meteor/tracker';

export const MyComponent = () => {
    Tracker.autorun(() => {
        console.log(Meteor.status().status);
    });
}

This will console log your connection status as it changes.

It can be helpful to include timestamps as well:

Tracker.autorun(() => {
    console.log(`${new Date().toLocaleTimeString('en-GB')} : ${Meteor.status().status}`);
});

Contributing

We welcome all contributions! Please enhance this with more logic to disconnect in a smart way. Some ideas:

  • Conditionally turn it on for some routes
  • Turn it off when the user stops interacting with your app (but might have it in the foreground)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].