-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
1,386 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,207 @@ | ||
<!DOCTYPE html> | ||
<!--[if IE]><![endif]--> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | ||
<title>Interface ISubscriber<TMessage> | ||
</title> | ||
<meta name="viewport" content="width=device-width"> | ||
<meta name="title" content="Interface ISubscriber<TMessage> | ||
"> | ||
<meta name="generator" content="docfx 2.41.0.0"> | ||
|
||
<link rel="shortcut icon" href="../favicon.ico"> | ||
<link rel="stylesheet" href="../styles/docfx.vendor.css"> | ||
<link rel="stylesheet" href="../styles/docfx.css"> | ||
<link rel="stylesheet" href="../styles/main.css"> | ||
<meta property="docfx:navrel" content="../toc.html"> | ||
<meta property="docfx:tocrel" content="toc.html"> | ||
|
||
|
||
|
||
</head> | ||
<body data-spy="scroll" data-target="#affix" data-offset="120"> | ||
<div id="wrapper"> | ||
<header> | ||
|
||
<nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation"> | ||
<div class="container"> | ||
<div class="navbar-header"> | ||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar"> | ||
<span class="sr-only">Toggle navigation</span> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
</button> | ||
|
||
<a class="navbar-brand" href="../index.html"> | ||
<img id="logo" class="svg" src="../logo.svg" alt=""> | ||
</a> | ||
</div> | ||
<div class="collapse navbar-collapse" id="navbar"> | ||
<form class="navbar-form navbar-right" role="search" id="search"> | ||
<div class="form-group"> | ||
<input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off"> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</nav> | ||
|
||
<div class="subnav navbar navbar-default"> | ||
<div class="container hide-when-search" id="breadcrumb"> | ||
<ul class="breadcrumb"> | ||
<li></li> | ||
</ul> | ||
</div> | ||
</div> | ||
</header> | ||
<div role="main" class="container body-content hide-when-search"> | ||
|
||
<div class="sidenav hide-when-search"> | ||
<a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a> | ||
<div class="sidetoggle collapse" id="sidetoggle"> | ||
<div id="sidetoc"></div> | ||
</div> | ||
</div> | ||
<div class="article row grid-right"> | ||
<div class="col-md-10"> | ||
<article class="content wrap" id="_content" data-uid="GoRogue.Messaging.ISubscriber`1"> | ||
|
||
|
||
<h1 id="GoRogue_Messaging_ISubscriber_1" data-uid="GoRogue.Messaging.ISubscriber`1" class="text-break">Interface ISubscriber<TMessage> | ||
</h1> | ||
<div class="markdown level0 summary"><p>Interface representing subscribers to messages sent over a <a class="xref" href="GoRogue.Messaging.MessageBus.html">MessageBus</a>. Classes wishing to respond to one or more message types as they are sent across | ||
the bus should implement this interface.</p> | ||
</div> | ||
<div class="markdown level0 conceptual"></div> | ||
<h6><strong>Namespace</strong>: <a class="xref" href="GoRogue.Messaging.html">GoRogue.Messaging</a></h6> | ||
<h6><strong>Assembly</strong>: GoRogue.dll</h6> | ||
<h5 id="GoRogue_Messaging_ISubscriber_1_syntax">Syntax</h5> | ||
<div class="codewrapper"> | ||
<pre><code class="lang-csharp hljs">public interface ISubscriber<TMessage></code></pre> | ||
</div> | ||
<h5 class="typeParameters">Type Parameters</h5> | ||
<table class="table table-bordered table-striped table-condensed"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Description</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td><span class="parametername">TMessage</span></td> | ||
<td><p>The type of message that the subscriber wants to handle. Any and all messages sent over the event bus you subscribe to | ||
that can cast to this type will be passed the <a class="xref" href="GoRogue.Messaging.ISubscriber-1.html#GoRogue_Messaging_ISubscriber_1_Handle__0_">Handle(TMessage)</a> function when they are sent.</p> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<h5 id="GoRogue_Messaging_ISubscriber_1_remarks"><strong>Remarks</strong></h5> | ||
<div class="markdown level0 remarks"><p>It is possible to have one class handle two different event types, by having it implement multiple ISubscriber types, passing different types as TMessage. | ||
When this is performed, however, the compiler will be unable to automatically resolve the template parameter of <a class="xref" href="GoRogue.Messaging.MessageBus.html#GoRogue_Messaging_MessageBus_RegisterSubscriber__1_GoRogue_Messaging_ISubscriber___0__">RegisterSubscriber<TMessage>(ISubscriber<TMessage>)</a>, | ||
so it will need to be specified manually. Further, the RegisterSubscriber function will need to be called once for each ISubscriber type the class implements. | ||
<example> | ||
In this example, MultipleSubscriber wants to respond to messages of both type string and string[], without using any component classes or any such method of splitting | ||
up the implementations. Thus, we implement the appropriate ISubscriber interfaces, and call the message bus's | ||
<a class="xref" href="GoRogue.Messaging.MessageBus.html#GoRogue_Messaging_MessageBus_RegisterSubscriber__1_GoRogue_Messaging_ISubscriber___0__">RegisterSubscriber<TMessage>(ISubscriber<TMessage>)</a> function once for each interface, explicitly specifying the type.<p> | ||
<pre><code>class MultipleSubscriber : ISubscriber<string>, ISubscriber<string[]> | ||
{ | ||
/* Explicit interface definitions are not required but are recommened for code clarity | ||
void ISubscriber<string>.Handle(string message) => Console.WriteLine(message); | ||
void ISubscriber<string[]>.Handle(string[] message) => Console.WriteLine(message.ExtendToString()); | ||
} | ||
|
||
/* Later, when we add the subscriber to our message bus, we add each subscriber interface seperately */ | ||
var messageBus = new MessageBus(); | ||
var multiSubber = new MultipleSubscriber(); | ||
messageBus.RegisterSubscriber<string>(multiSubber); | ||
messageBus.RegisterSubscriber<string[]>(multiSubber);</code></pre> | ||
</example> | ||
</div> | ||
<h3 id="methods">Methods | ||
</h3> | ||
<span class="small pull-right mobile-hide"> | ||
<span class="divider">|</span> | ||
<a href="https://github.com/Chris3606/GoRogue/new/master/apiSpec/new?filename=GoRogue_Messaging_ISubscriber_1_Handle__0_.md&value=---%0Auid%3A%20GoRogue.Messaging.ISubscriber%601.Handle(%600)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a> | ||
</span> | ||
<span class="small pull-right mobile-hide"> | ||
<a href="https://github.com/Chris3606/GoRogue/blob/master/GoRogue/Messaging/ISubscriber.cs/#L40">View Source</a> | ||
</span> | ||
<a id="GoRogue_Messaging_ISubscriber_1_Handle_" data-uid="GoRogue.Messaging.ISubscriber`1.Handle*"></a> | ||
<h4 id="GoRogue_Messaging_ISubscriber_1_Handle__0_" data-uid="GoRogue.Messaging.ISubscriber`1.Handle(`0)">Handle(TMessage)</h4> | ||
<div class="markdown level1 summary"><p>Function that should handle the specified type of message in whatever manner it needs to. Called automatically any time a message is sent | ||
over an event bus this subscriber has been registered on.</p> | ||
</div> | ||
<div class="markdown level1 conceptual"></div> | ||
<h5 class="decalaration">Declaration</h5> | ||
<div class="codewrapper"> | ||
<pre><code class="lang-csharp hljs">void Handle(TMessage message)</code></pre> | ||
</div> | ||
<h5 class="parameters">Parameters</h5> | ||
<table class="table table-bordered table-striped table-condensed"> | ||
<thead> | ||
<tr> | ||
<th>Type</th> | ||
<th>Name</th> | ||
<th>Description</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td><span class="xref">TMessage</span></td> | ||
<td><span class="parametername">message</span></td> | ||
<td><p>Message that was sent.</p> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<h3 id="extensionmethods">Extension Methods</h3> | ||
<div> | ||
<a class="xref" href="GoRogue.Utility.html#GoRogue_Utility_Yield__1___0_">Utility.Yield<T>(T)</a> | ||
</div> | ||
</article> | ||
</div> | ||
|
||
<div class="hidden-sm col-md-2" role="complementary"> | ||
<div class="sideaffix"> | ||
<div class="contribution"> | ||
<ul class="nav"> | ||
<li> | ||
<a href="https://github.com/Chris3606/GoRogue/new/master/apiSpec/new?filename=GoRogue_Messaging_ISubscriber_1.md&value=---%0Auid%3A%20GoRogue.Messaging.ISubscriber%601%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A" class="contribution-link">Improve this Doc</a> | ||
</li> | ||
<li> | ||
<a href="https://github.com/Chris3606/GoRogue/blob/master/GoRogue/Messaging/ISubscriber.cs/#L33" class="contribution-link">View Source</a> | ||
</li> | ||
</ul> | ||
</div> | ||
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix"> | ||
<!-- <p><a class="back-to-top" href="#top">Back to top</a><p> --> | ||
</nav> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<footer> | ||
<div class="grad-bottom"></div> | ||
<div class="footer"> | ||
<div class="container"> | ||
<span class="pull-right"> | ||
<a href="#top">Back to top</a> | ||
</span> | ||
|
||
<span>Generated by <strong>DocFX</strong></span> | ||
</div> | ||
</div> | ||
</footer> | ||
</div> | ||
|
||
<script type="text/javascript" src="../styles/docfx.vendor.js"></script> | ||
<script type="text/javascript" src="../styles/docfx.js"></script> | ||
<script type="text/javascript" src="../styles/main.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.