Code Monkey home page Code Monkey logo

meteor-smart-disconnect's Introduction

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.

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)

meteor-smart-disconnect's People

Contributors

bradvogel avatar bradwalton avatar elie222 avatar nerdmed avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.