How to detect when the content of a canvas was changed?
<p>I need to watch the changes in an canvas object (I'm using fabricjs library). </p>

<pre><code>var canvas = this.__canvas = new fabric.Canvas('canvas', {isDrawingMode:true});
//I need to watch the changes here -&gt; 
canvas.toJSON();
</code></pre>

<p>I try out with <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/watch" rel="nofollow">Object.prototype.watch()</a> like:</p>

<blockquote>
  <p>canvas.toJSON.watch('objects', function(){
     //dosomething});</p>
</blockquote>

<p>But that hasn't worked for me, any help?</p>