1.1.2 • Published 3 years ago

io-timers v1.1.2

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

io-timers

How to use

const IoTimers = require('io-timers');
const ioTimers = IoTimers({ host: 'localhost', port: 6379 });

API

IoTimers(uri, opts)

uri is a string like localhost:6379 where your redis server is located. For a list of options see below.

IoTimers(opts)

The following options are allowed:

  • key: the name of the key to pub/sub events on as prefix (io-timers)
  • host: host to connect to redis on (localhost)
  • port: port to connect to redis on (6379)
  • pubClient: optional, the redis client to publish events on
  • subClient: optional, the redis client to subscribe to events on

If you decide to supply pubClient and subClient, make sure you use node_redis as a client or one with an equivalent API.

IoTimers#startTimer(timerId: String, timeout: Number, opts: Any)

Start Timer with give time durationin Seconds timerId should be unique

ioTimers.startTimer("abcTimerId", 10);

IoTimers#remaingTimer(timerId: String)

Returns remaining time of particular timerId.

let remainingTime = await ioTimers.remainingTimer("abcTimerId");

IoTimers#stopTimer(timerId: String)

Stop timer

ioTimers.stopTimer("abcTimerId");

IoTimers#timers(id:String, room:String)

Add Listener if any timeout

ioTimers.timers.on("timeout", function(timerId, opts){
    console.log(timerId, opts);
})

Client error handling

Error Handling

ioTimers.timers.on("error", function(err){
    //Handle Error
})

License

ISC

1.1.1

3 years ago

1.1.2

3 years ago

1.0.2

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.0

3 years ago