GithubHelp home page GithubHelp logo

sirpy / meteor-events Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mcbrumagin/meteor-events

0.0 1.0 0.0 4 KB

Client & Server Reactive Events for Meteor

License: MIT License

CoffeeScript 85.68% JavaScript 14.32%

meteor-events's Introduction

meteor-events

Client & Server Reactive Events for Meteor

Overview

Meteor events can be bound on client, server, or both the same way. Meteor events can be emitted from client and server, and will broadcast to the server (if it is listening) as well as all clients.

You can use this to have a consistent way of doing simple meteor methods, or to have events synchronized across clients and the server.

Examples

// Binding events

Events.on('printSomething', function (something, data) {
    console.log(something, data)
})

if (Meteor.isClient /* can also be in a client directory */) {
    Events.on('doSomethingOnAllClients', function (data) {
        doSomething(data)
    })
}

if (Meteor.isServer /* can also be in a server directory */) {
    Events.on('doSomethingOnTheServer', function (data) {
        doSomething(data)
    })
}


// Emitting events

// Sends this event to all clients and the server
Events.emit('printSomething', 'Some awesome text', myVar)

if (Meteor.isClient /* can also be in a client directory */)
    Events.emit('doSomethingOnAllClients', {name: 'Bob', age: 83})

if (Meteor.isServer /* can also be in a server directory */)
    Events.emit('doSomethingOnTheServer', {name: 'Bob', age: 83})

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.