Skip to content

Angular Service Provider for Interacting with the Redis PubSub System with Webdis

Notifications You must be signed in to change notification settings

roboza/angular-webdis

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Angular-Webdis

Angular-Webdis is an angular provider that allows you to subscribe to Redis PubSub channels via Webdis using WebSockets.

Installation

Angular-Webdis can be installed by either downloading angular-webdis.min.js from the dist directory in this repository, or with bower install angular-webdis.

Installing Webdis (Laravel Forge Users)

Laravel Forge users can use the Laravel Forge Recipe at ForgeRecipes.com.

Configuration

You can configure the provider like so:

myApp = angular.module('my-app', ['adamgoose.webdis']);

myApp.config(['WebdisProvider', function(WebdisProvider)
  {
    // Your Webdis Host
    WebdisProvider.setHost('example.com');

    // Your Webdis Port (7379 by default)
    WebdisProvider.setPort(7379);
  }]);

WebdisProvider.setHost(host)

Sets the host for the Webdis Requests

  • host: Your Webdis Host

WebdisProvider.setPort(port)

Sets the port for the Webdis Requests

  • port: Your Webdis Post (default 7379)

Usage

To subscribe to a channel, inject Webdis to your controllers, and use the provided methods (see below) to subscribe to channels.

app.controller('DemoCtl', ['$scope', 'Webdis', function($scope, Webdis)
{

  Webdis.subscribe('my-channel', function(data, channel)
    {
      console.log('Message received on channel '+channel+': '+data);
    }, $scope);

}]);

API

Webdis.subscribe(channel, callback, scope)

Subscribe to a channel.

  • channel: Channel to subscribe to.
  • callback: Function to handle the callback. See below for more documentation.
  • scope: Pass in your scope, and we'll run $scope.$apply() after your callbacks for you.

callback(message, channel)

The callback that handles messages sent to a particular subscribed channel.

  • message: JSON Object or String message data
  • channel: Channel on which the message was sent

Note: If you do not pass your scope to the .subscribe() method, you will need to run $scope.$apply() in your callbacks if you make changes to your scope within the callback.

Contributing

Do it nicely, please. :)

Before you commit, please run the following commands to build out the dist files.

npm install
gulp

About

Angular Service Provider for Interacting with the Redis PubSub System with Webdis

Resources

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • JavaScript 100.0%