Skip to content

Commit

Permalink
param-source: fix cleanup of old events
Browse files Browse the repository at this point in the history
  • Loading branch information
mmckegg committed Dec 30, 2017
1 parent fb37ecc commit 8186584
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/param-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ function ReducedParams (params, reducer) {
this.params = params
this.reducer = reducer
this.events = []
this.context = getContext(params)
}

ReducedParams.prototype.onEvent = function (listener) {
var context = this.params[0] && this.params[0].context
var context = this.context
var releases = this.params.map(param => ParamSource.isParam(param) && param.onEvent((event) => {
var duration = 0
var sampleTime = event.time
Expand Down Expand Up @@ -196,3 +197,11 @@ function cancelScheduledValues (source, time) {
function last (array) {
return array[array.length - 1]
}

function getContext (params) {
for (var i = 0; i < params.length; i++) {
if (params[i] && params[i].context) {
return params[i].context
}
}
}

0 comments on commit 8186584

Please sign in to comment.