Skip to content

Commit

Permalink
Added remove method to Store, used when removing processed one-time e…
Browse files Browse the repository at this point in the history
…vents
  • Loading branch information
JvrBaena committed Jan 23, 2014
1 parent 2c3ef41 commit 95d1d05
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/PersistentScheduler.coffee
Expand Up @@ -125,8 +125,9 @@ class PersistentScheduler extends Scheduler
if err then throw new util.Error err

todoEvents = unsolvedOneTimeEvents.concat oneTimeEvents
for {timestamp, event, payload} in todoEvents
for {id, timestamp, event, payload} in todoEvents
@schedule timestamp, event, payload
@store.remove id, () ->


# Public api.
Expand Down
10 changes: 10 additions & 0 deletions src/Store.coffee
Expand Up @@ -148,6 +148,16 @@ class Store

return callback null, event.done is true

remove: (eventId, callback) ->
###
Removes a one-time event.
@return {Boolean} whether the event was removed or not.
###
@EventModel.remove {_id: eventId},
(err) ->
if err? then return callback err
return callback null, true


# Public API
module.exports = Store

0 comments on commit 95d1d05

Please sign in to comment.