title: Java script how to pass around an object with event being attached
body: <p>I have a custom object that being passed around. I want to show a toast when a workflow is done. 
  I am looking for some thing like</p>
  
  <pre><code>object.addEvent("workflowIsDone", ()=&gt; {
      toast.open();
  });
  </code></pre>
  
  <p>and when the workflow ends:</p>
  
  <pre><code>object.fireEvent("workFlowIsDone")
  </code></pre>
  
  <p>I was wondering if some one can tell me how to do it in Javascript</p>