Skip to content

Commit

Permalink
Merge pull request #15 from chris-rudmin/stop-event
Browse files Browse the repository at this point in the history
Publish stop after last dataAvailable event
  • Loading branch information
chris-rudmin committed May 12, 2015
2 parents 1ae28b6 + 282bcdd commit 798ffdd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,14 @@ Recorder.prototype.stop = function(){
this.monitorNode.disconnect();
this.scriptProcessorNode.disconnect();
this.state = "inactive";
this.eventTarget.dispatchEvent( new Event( 'stop' ) );

var that = this;
var publishStop = function( e ) {
that.eventTarget.dispatchEvent( new Event( 'stop' ) );
that.worker.removeEventListener( "message", publishStop );
};

this.worker.addEventListener( "message", publishStop );
this.worker.postMessage({ command: "requestData" });
this.worker.postMessage({ command: "stop" });
}
Expand Down

0 comments on commit 798ffdd

Please sign in to comment.