Giter Site home page Giter Site logo

lookback / meteor-event-hooks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from benjaminrh/meteor-event-hooks

0.0 15.0 1.0 117 KB

Provides hooks for various user-triggered events.

Home Page: https://atmosphere.meteor.com/package/event-hooks

JavaScript 100.00%

meteor-event-hooks's Introduction

Event Hooks - Meteor Smart Package

endorse

Provides hooks for various user-triggered events.

API

Currently, all API methods on the server take a userId argument.

  • Hooks.onLoggedIn = function ([server: userId]) { ... } ( anywhere ) - Provide a callback to run when a user has logged in
  • Hooks.onLoggedOut = function (userId) { ... } ( anywhere ) - Provide a callback to run when a user has logged out
  • Hooks.onCreateUser = function (userId) { ... } ( server ) - Provide a callback to run when a user is created
  • Hooks.onDeleteUser = function (userId) { ... } ( server ) - Provide a callback to run when a user is deleted
  • Hooks.onLoseFocus = function ([server: userId]) { ... } ( anywhere )* - Provide a callback to run when the window loses focus. * Opt-in through the updateFocus option
  • Hooks.onGainFocus = function ([server: userId]) { ... } ( anywhere )* - Provide a callback to run when the window gains focus * Opt-in through the updateFocus option
  • Hooks.onCloseSession = function ([server: userId]) { ... } ( server ) - Provide a callback to run when the window/tab is closed

Initialization

  • Hooks.init([options]) ( client ) - Initialize the event system. Optionally provide an Object to set the options. Put this in your Meteor.startup

Options

Options are specified on the client side as an argument (object) in the init method.

  • updateFocus ( Integer ) - Number of milliseconds to wait before checking whether the window is focused. Default is 0, meaning unless you change this, the onLoseFocus and onGainFocus methods won't be available
  • treatCloseAsLogout ( Boolean ) - If true, treat closing the browser window as logging off (meaning that the onLoggedOut callback is triggered in addition to the onCloseSession). Default is false

How to use?

  1. Install meteorite
  2. mrt add event-hooks
  3. Add Hooks.init() to your Meteor.startup inside of a file inside your client/ directory or inside of an if(Meteor.isClient) block.
if(Meteor.isClient){
	Meteor.startup(function(){
		Hooks.init();
	});
}

That's it!

meteor-event-hooks's People

Contributors

benjaminrh avatar datacarl avatar awatson1978 avatar johanbrook avatar

Watchers

Neil Kinnish avatar Andreas Smas avatar Jonatan Littke avatar Francis Byrne avatar  avatar Pete Nelson avatar James Cloos avatar  avatar Frida Issa avatar Marcin Mikosik avatar craig james avatar Scott Edgar avatar  avatar  avatar  avatar

Forkers

yerffejytnac

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.