# Wijmo.Event

## Content

<div class="content__tsd">
						<div style="display:flex;justify-content:space-between;align-items:center">
							<h1>
								Event Class
							</h1>
						</div>
						<section class="tsd-comment">
							<div class="tsd-comment">
								<div class="lead">
									<p>Represents an event.</p>
								</div>
								<p>Wijmo events are similar to .NET events. Any class may define events by
									declaring them as fields. Any class may subscribe to events using the
									event's <a href="wijmo.event.html#addhandler">addHandler</a> method and unsubscribe using the <a href="wijmo.event.html#removehandler">removeHandler</a>
								method.</p>
								<p>Wijmo event handlers take two parameters: <i>sender</i> and <i>args</i>.
									The first is the object that raised the event, and the second is an object
								that contains the event parameters.</p>
								<p>Classes that define events follow the .NET pattern where for every event
									there is an <i>on[EVENTNAME]</i> method that raises the event. This pattern
									allows derived classes to override the <i>on[EVENTNAME]</i> method and
									handle the event before and/or after the base class raises the event.
									Derived classes may even suppress the event by not calling the base class
								implementation.</p>
								<p>For example, the TypeScript code below overrides the <b>onValueChanged</b>
									event for a control to perform some processing before and after the
								<b>valueChanged</b> event fires:</p>
								<pre>// override base class
onValueChanged(e: EventArgs) {
  // execute some code before the event fires
  console.log('about to fire valueChanged');
  // optionally, call base class to fire the event
  super.onValueChanged(e);
  // execute some code after the event fired
  console.log('valueChanged event just fired');
}</pre>
							</div>
						</section>
						<section class="tsd-type-parameters">
							<h3>Type parameters</h3>
							<ul class="tsd-type-parameters">
								<li>
									<h4>S</h4>
								</li>
								<li>
									<h4>T</h4>
								</li>
							</ul>
						</section>
						<section class="tsd-hierarchy">
							<h3>Heirarchy</h3>
							<ul class="tsd-hierarchy">
								<li>
									<span class="target">Event</span>
								</li>
							</ul>
						</section>
						<section class="tsd-index-group">
							<section class="tsd-index-panel">
								<div class="tsd-index-content">
									<section class="tsd-index-section ">
										<div class="title">
											<div class="gc_api_tree-item_icon_img_wrapper">
												<div class="gc_api_tree-item_icon_img" data-expand="true">
												</div>
											</div>
											<h3>
												Constructors
											</h3>
										</div>
										<ul class="tsd-index-list">
											<li class="tsd-kind-constructor tsd-parent-kind-class"><a href="wijmo.event.html#constructor" class="tsd-kind-icon">constructor</a></li>
										</ul>
									</section>
									<section class="tsd-index-section ">
										<div class="title">
											<div class="gc_api_tree-item_icon_img_wrapper">
												<div class="gc_api_tree-item_icon_img" data-expand="true">
												</div>
											</div>
											<h3>
												Properties
											</h3>
										</div>
										<ul class="tsd-index-list">
											<li class="tsd-kind-property tsd-parent-kind-class"><a href="wijmo.event.html#handlercount" class="tsd-kind-icon">handler<wbr>Count</a></li>
											<li class="tsd-kind-property tsd-parent-kind-class"><a href="wijmo.event.html#hashandlers" class="tsd-kind-icon">has<wbr>Handlers</a></li>
										</ul>
									</section>
									<section class="tsd-index-section ">
										<div class="title">
											<div class="gc_api_tree-item_icon_img_wrapper">
												<div class="gc_api_tree-item_icon_img" data-expand="true">
												</div>
											</div>
											<h3>
												Methods
											</h3>
										</div>
										<ul class="tsd-index-list">
											<li class="tsd-kind-method tsd-parent-kind-class"><a href="wijmo.event.html#addhandler" class="tsd-kind-icon">add<wbr>Handler</a></li>
											<li class="tsd-kind-method tsd-parent-kind-class"><a href="wijmo.event.html#gethandler" class="tsd-kind-icon">get<wbr>Handler</a></li>
											<li class="tsd-kind-method tsd-parent-kind-class"><a href="wijmo.event.html#raise" class="tsd-kind-icon">raise</a></li>
											<li class="tsd-kind-method tsd-parent-kind-class"><a href="wijmo.event.html#removeallhandlers" class="tsd-kind-icon">remove<wbr>All<wbr>Handlers</a></li>
											<li class="tsd-kind-method tsd-parent-kind-class"><a href="wijmo.event.html#removehandler" class="tsd-kind-icon">remove<wbr>Handler</a></li>
										</ul>
									</section>
								</div>
							</section>
						</section>
						<section class="tsd-panel-group tsd-member-group ">
							<h2>Constructors</h2>
							<section class="tsd-panel tsd-member tsd-kind-constructor tsd-parent-kind-class">
								<a name="constructor" class="tsd-anchor"></a>
								<h3>constructor</h3>
								<ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-class">
									<li class="tsd-signature tsd-kind-icon">new <wbr>Event<span class="tsd-signature-symbol">(</span>handlersChanged<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Function</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="wijmo.event.html" class="tsd-signature-type">Event</a></li>
								</ul>
								<ul class="tsd-descriptions">
									<li class="tsd-description">
										<aside class="tsd-sources">
										</aside>
										<div class="tsd-comment">
											<div class="lead">
												<p>Initializes a new instance of an <a href="wijmo.event.html">Event</a>.</p>
											</div>
										</div>
										<h4 class="tsd-parameters-title">Parameters</h4>
										<ul class="tsd-parameters">
											<li>
												<h5><span class="tsd-flag ts-flagOptional">Optional</span> handlersChanged: <span class="tsd-signature-type">Function</span></h5>
												<div class="tsd-comment">
													<div class="lead">
														<p>Optional callback invoked when handlers are
														added or removed from this <a href="wijmo.event.html">Event</a>.</p>
													</div>
												</div>
											</li>
										</ul>
										<h4 class="tsd-returns-title">Returns <a href="wijmo.event.html" class="tsd-signature-type">Event</a></h4>
									</li>
								</ul>
							</section>
						</section>
						<section class="tsd-panel-group tsd-member-group ">
							<h2>Properties</h2>
							<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class">
								<a name="handlercount" class="tsd-anchor"></a>
								<h3>handlerCount</h3>
								<div class="tsd-signature tsd-kind-icon">handler<wbr>Count<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
								<aside class="tsd-sources">
								</aside>
								<div class="tsd-comment">
									<div class="lead">
										<p>Gets the number of handlers added to this event.</p>
									</div>
								</div>
							</section>
							<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class">
								<a name="hashandlers" class="tsd-anchor"></a>
								<h3>hasHandlers</h3>
								<div class="tsd-signature tsd-kind-icon">has<wbr>Handlers<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span></div>
								<aside class="tsd-sources">
								</aside>
								<div class="tsd-comment">
									<div class="lead">
										<p>Gets a value that indicates whether this event has any handlers.</p>
									</div>
								</div>
							</section>
						</section>
						<section class="tsd-panel-group tsd-member-group ">
							<h2>Methods</h2>
							<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
								<a name="addhandler" class="tsd-anchor"></a>
								<h3>addHandler</h3>
								<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
									<li class="tsd-signature tsd-kind-icon">add<wbr>Handler<span class="tsd-signature-symbol">(</span>handler<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">IEventHandler</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span>, self<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
								</ul>
								<ul class="tsd-descriptions">
									<li class="tsd-description">
										<aside class="tsd-sources">
										</aside>
										<div class="tsd-comment">
											<div class="lead">
												<p>Adds a handler to this event.</p>
											</div>
										</div>
										<h4 class="tsd-parameters-title">Parameters</h4>
										<ul class="tsd-parameters">
											<li>
												<h5>handler: <span class="tsd-signature-type">IEventHandler</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span></h5>
												<div class="tsd-comment">
													<p>Function invoked when the event is raised.</p>
												</div>
											</li>
											<li>
												<h5><span class="tsd-flag ts-flagOptional">Optional</span> self: <span class="tsd-signature-type">any</span></h5>
												<div class="tsd-comment">
													<p>Object that defines the event handler
													(accessible as 'this' from the handler code).</p>
												</div>
											</li>
										</ul>
										<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
									</li>
								</ul>
							</section>
							<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
								<a name="gethandler" class="tsd-anchor"></a>
								<h3>getHandler</h3>
								<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
									<li class="tsd-signature tsd-kind-icon">get<wbr>Handler<span class="tsd-signature-symbol">(</span>index<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">IEventHandler</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">void</span></li>
								</ul>
								<ul class="tsd-descriptions">
									<li class="tsd-description">
										<aside class="tsd-sources">
										</aside>
										<div class="tsd-comment">
											<div class="lead">
												<p>Gets a handler to this event.</p>
											</div>
										</div>
										<h4 class="tsd-parameters-title">Parameters</h4>
										<ul class="tsd-parameters">
											<li>
												<h5><span class="tsd-flag ts-flagOptional">Optional</span> index: <span class="tsd-signature-type">number</span></h5>
												<div class="tsd-comment">
													<p>Desired handle index number, this is usually zero.</p>
												</div>
											</li>
										</ul>
										<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">IEventHandler</span>
											<span class="tsd-signature-symbol"> | </span>
											<span class="tsd-signature-type">void</span>
										</h4>
									</li>
								</ul>
							</section>
							<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
								<a name="raise" class="tsd-anchor"></a>
								<h3>raise</h3>
								<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
									<li class="tsd-signature tsd-kind-icon">raise<span class="tsd-signature-symbol">(</span>sender<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span>, args<span class="tsd-signature-symbol">?: </span><a href="wijmo.eventargs.html" class="tsd-signature-type">EventArgs</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
								</ul>
								<ul class="tsd-descriptions">
									<li class="tsd-description">
										<aside class="tsd-sources">
										</aside>
										<div class="tsd-comment">
											<div class="lead">
												<p>Raises this event, causing all associated handlers to be invoked.</p>
											</div>
										</div>
										<h4 class="tsd-parameters-title">Parameters</h4>
										<ul class="tsd-parameters">
											<li>
												<h5>sender: <span class="tsd-signature-type">any</span></h5>
												<div class="tsd-comment">
													<p>Source object.</p>
												</div>
											</li>
											<li>
												<h5><span class="tsd-flag ts-flagOptional">Optional</span> args: <a href="wijmo.eventargs.html" class="tsd-signature-type">EventArgs</a></h5>
												<div class="tsd-comment">
													<p>Event parameters.</p>
												</div>
											</li>
										</ul>
										<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
									</li>
								</ul>
							</section>
							<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
								<a name="removeallhandlers" class="tsd-anchor"></a>
								<h3>removeAllHandlers</h3>
								<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
									<li class="tsd-signature tsd-kind-icon">remove<wbr>All<wbr>Handlers<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
								</ul>
								<ul class="tsd-descriptions">
									<li class="tsd-description">
										<aside class="tsd-sources">
										</aside>
										<div class="tsd-comment">
											<div class="lead">
												<p>Removes all handlers associated with this event.</p>
											</div>
										</div>
										<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
									</li>
								</ul>
							</section>
							<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
								<a name="removehandler" class="tsd-anchor"></a>
								<h3>removeHandler</h3>
								<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
									<li class="tsd-signature tsd-kind-icon">remove<wbr>Handler<span class="tsd-signature-symbol">(</span>handler<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">IEventHandler</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span>, self<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
								</ul>
								<ul class="tsd-descriptions">
									<li class="tsd-description">
										<aside class="tsd-sources">
										</aside>
										<div class="tsd-comment">
											<div class="lead">
												<p>Removes a handler from this event.</p>
											</div>
										</div>
										<h4 class="tsd-parameters-title">Parameters</h4>
										<ul class="tsd-parameters">
											<li>
												<h5>handler: <span class="tsd-signature-type">IEventHandler</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">S</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">T</span><span class="tsd-signature-symbol">&gt;</span></h5>
												<div class="tsd-comment">
													<p>Function invoked when the event is raised.</p>
												</div>
											</li>
											<li>
												<h5><span class="tsd-flag ts-flagOptional">Optional</span> self: <span class="tsd-signature-type">any</span></h5>
												<div class="tsd-comment">
													<p>Object that owns the event handler (accessible as 'this' from the handler code).</p>
												</div>
											</li>
										</ul>
										<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
									</li>
								</ul>
							</section>
						</section>
					</div>