I am trying to register for events on a JavaScript function/class, and am trying to get it as close as possible to my C# class below. Is this possible in any way?
C#
public class MyClass
{
public event EventHandler evtMyEvent;
private void RaiseEvent()
{
if(evtMyEvent != null)
evtMyEvent(this, new EventArgs());
}
}
MyClass mc = new MyClass();
mc.evtMyEvent += (s,e) => { //Do Something };
JS
function MyClass()
{
// Add an event handler...
this.raiseEvent = function(){
// raise the event
}
}
var mc = new MyClass();
//register for the event