 
     # [INTERNAL] publish to available outputs
     _publish: (event,id) ->
-        @redisClient.publish event, id  if @redisClient?
+        @redisClient.publish event, id  if @redisConnected?
 
     # [INTERNAL]  transform db change to (doctype.op, id) message and publish
     _onChange: (change) =>

    # redisClient a redis client
    startPublishingToRedis: () ->
        redis = require('redis')
        @redisClient = redis.createClient REDIS_PORT, REDIS_HOST,
            max_attempts: 1
        @redisClient.on "error", (err) =>
            console.log "Failled to connect to redis : #{err.stack}"
            console.log "Everything else should work as expected"
        @redisClient.on "connect", =>
            console.log "Begins publishing changes to redis"

    publish: (event, id) => @_publish(event, id)

REDIS_PORT = 6379
REDIS_HOST = "127.0.0.1"

REDIS_CONNECT_COUNTER = 1

module.exports = class Feed

