<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Events.EventMapper - SamsaraJS</title>
    <link rel="stylesheet" href="">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
    <link rel="stylesheet" href="../assets/css/custom.css">
    <link rel="stylesheet" href="../assets/vendor/bootstrap/css/bootstrap.css">
    <link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
</head>
<body class="yui3-skin-sam">
<div class="navbar navbar-fixed-top">
    <div class="navbar-inner">
        <h1 class="brand" style="padding: 10px 16px 10px; height: 20px; line-height: 20px; margin-left: 0;">
        <!---->
	    <!--<img alt="SamsaraJS" src="../assets/css/logo.png" style="max-height: 65%;" title="SamsaraJS">-->
        <!---->
            SamsaraJS
        </h1>
	<div class="nav">
            <li class="divider-vertical"></li>
            <li>
                <p class="navbar-text">
                    API Docs for Version: <b>0.2.2</b>
                </p>
            </li>
        </div>
        <form class="navbar-form pull-right" style="line-height: 40px; height: 40px;">
            <input style="margin-top: 0;" type="text" class="search-query" placeholder="Search for classes..." data-obj='["classes/Core.Controller", "classes/Core.DOMAllocator", "classes/Core.DOMOutput", "classes/Core.Engine", "classes/Core.LayoutNode", "classes/Core.Node", "classes/Core.OptionsManager", "classes/Core.RenderTreeNode", "classes/Core.RootNode", "classes/Core.SizeNode", "classes/Core.Timer", "classes/Core.Transform", "classes/Core.Transitionable", "classes/Core.View", "classes/DOM.ContainerSurface", "classes/DOM.Context", "classes/DOM.Surface", "classes/Events.EventEmitter", "classes/Events.EventFilter", "classes/Events.EventHandler", "classes/Events.EventMapper", "classes/Events.EventSplitter", "classes/Inputs.GenericInput", "classes/Inputs.MouseInput", "classes/Inputs.PinchInput", "classes/Inputs.RotateInput", "classes/Inputs.ScaleInput", "classes/Inputs.ScrollInput", "classes/Inputs.TouchInput", "classes/Inputs.TouchTracker", "classes/Inputs.TwoFingerInput", "classes/Layouts.BidirectionalList", "classes/Layouts.DrawerLayout", "classes/Layouts.FlexLayout", "classes/Layouts.GridLayout", "classes/Layouts.HeaderFooterLayout", "classes/Layouts.SequentialLayout", "classes/Streams.Accumulator", "classes/Streams.Differential", "classes/Streams.Observable", "classes/Streams.SimpleStream", "classes/Streams.Stream", "classes/Transitions.Inertia", "classes/Transitions.Spring", "classes/Transitions.Tween", "classes/UI.Fingers", "classes/UI.Slider"]'>
        </form>
    </div>
</div>
<div class="container">
    <div class="row">
        <div class="span3">
	    <div>
	        <!--<h3>APIs</h3>-->
	        <br>
	        <div id="sidebar">
	            <!--<ul id="main-nav" class="nav nav-tabs" style="margin-bottom:0;">-->
	                <!--<li class="active"><a href="#classes" data-toggle="tab">Classes</a></li>-->
	                <!--<li><a href="#modules" data-toggle="tab">Modules</a></li>-->
	            <!--</ul>-->
	    
	            <div id="api-tabview-filter">
	                <input type="search" placeholder="Type to filter APIs">
	            </div>
	    
	            <div class="tab-content" style="border: 1px solid #DDD; border-top:0;">
	                <div class="tab-pane active" id="classes">
	                    <ul id="api-classes" class="nav nav-list">
	                            <li><a href="../classes/Core.Timer.html">Core.Timer</a></li>
	                            <li><a href="../classes/Core.Transform.html">Core.Transform</a></li>
	                            <li><a href="../classes/Core.Transitionable.html">Core.Transitionable</a></li>
	                            <li><a href="../classes/Core.View.html">Core.View</a></li>
	                            <li><a href="../classes/DOM.ContainerSurface.html">DOM.ContainerSurface</a></li>
	                            <li><a href="../classes/DOM.Context.html">DOM.Context</a></li>
	                            <li><a href="../classes/DOM.Surface.html">DOM.Surface</a></li>
	                            <li><a href="../classes/Events.EventEmitter.html">Events.EventEmitter</a></li>
	                            <li><a href="../classes/Events.EventFilter.html">Events.EventFilter</a></li>
	                            <li><a href="../classes/Events.EventHandler.html">Events.EventHandler</a></li>
	                            <li><a href="../classes/Events.EventMapper.html">Events.EventMapper</a></li>
	                            <li><a href="../classes/Inputs.GenericInput.html">Inputs.GenericInput</a></li>
	                            <li><a href="../classes/Inputs.MouseInput.html">Inputs.MouseInput</a></li>
	                            <li><a href="../classes/Inputs.PinchInput.html">Inputs.PinchInput</a></li>
	                            <li><a href="../classes/Inputs.RotateInput.html">Inputs.RotateInput</a></li>
	                            <li><a href="../classes/Inputs.ScaleInput.html">Inputs.ScaleInput</a></li>
	                            <li><a href="../classes/Inputs.ScrollInput.html">Inputs.ScrollInput</a></li>
	                            <li><a href="../classes/Inputs.TouchInput.html">Inputs.TouchInput</a></li>
	                            <li><a href="../classes/Layouts.BidirectionalList.html">Layouts.BidirectionalList</a></li>
	                            <li><a href="../classes/Layouts.DrawerLayout.html">Layouts.DrawerLayout</a></li>
	                            <li><a href="../classes/Layouts.FlexLayout.html">Layouts.FlexLayout</a></li>
	                            <li><a href="../classes/Layouts.GridLayout.html">Layouts.GridLayout</a></li>
	                            <li><a href="../classes/Layouts.HeaderFooterLayout.html">Layouts.HeaderFooterLayout</a></li>
	                            <li><a href="../classes/Layouts.SequentialLayout.html">Layouts.SequentialLayout</a></li>
	                            <li><a href="../classes/Streams.Accumulator.html">Streams.Accumulator</a></li>
	                            <li><a href="../classes/Streams.Differential.html">Streams.Differential</a></li>
	                            <li><a href="../classes/Streams.Stream.html">Streams.Stream</a></li>
	                            <li><a href="../classes/UI.Fingers.html">UI.Fingers</a></li>
	                            <li><a href="../classes/UI.Slider.html">UI.Slider</a></li>
	                    </ul>
	                </div>
	    
	                <!--<div class="tab-pane" id="modules">-->
	                    <!--<ul id="api-modules" class="nav nav-list">-->
	                        <!---->
	                    <!--</ul>-->
	                <!--</div>-->
	            </div>
	        </div>
	    </div>
        </div>
        <div class="span9">
                <form id="options-form" class="form-inline pull-right">
                    Show:
                    <label for="api-show-inherited" class="checkbox">
                        <input type="checkbox" id="api-show-inherited" checked>
                        Inherited
                    </label>
            
                    <label for="api-show-protected" class="checkbox">
                        <input type="checkbox" id="api-show-protected">
                        Protected
                    </label>
            
                    <label for="api-show-private" class="checkbox">
                        <input type="checkbox" id="api-show-private">
                        Private
                    </label>
                    <label for="api-show-deprecated" class="checkbox">
                        <input type="checkbox" id="api-show-deprecated">
                        Deprecated
                    </label>
            
                </form>
            
            <div class="apidocs">
                <div id="docs-main">
                    <div class="content">
<div class="page-header">
    <h1>Events.EventMapper <small>Class</small></h1>
</div>

<div class="well well-small">


    <!---->
        <div class="foundat">
            Defined in: <a href="../files/samsara_events_EventMapper.js.html#l6"><code>samsara&#x2F;events&#x2F;EventMapper.js:6</code></a>
        </div>
    <!---->


</div>


<div class="well well-small">
    <p>EventMapper modifies the data payload of an event based on
a provided function.</p>
<p>Note: it does not modify the event's <code>type</code>.</p>

</div>

    <div class="constructor">
        <h2>Constructor</h2>
        <div id="method_Events.EventMapper" class="method item">
            <h3 class="name"><code>Events.EventMapper</code></h3>
        
                <div class="args">
                    <span class="paren">(</span><ul class="args-list inline commas">
                        <li class="arg">
                                <code>map</code>
                        </li>
                    </ul><span class="paren">)</span>
                </div>
        
        
        
        
        
        
        
        
            <div class="meta">
                        <p>
                        <!---->
                        <!--Defined in-->
                        <!---->
                <!---->
                <!--<a href="../files/samsara_events_EventMapper.js.html#l6"><code>samsara&#x2F;events&#x2F;EventMapper.js:6</code></a>-->
                <!---->
                </p>
        
        
        
            </div>
        
            <div class="description">
                
            </div>
        
                <div class="params">
                    <h4>Parameters:</h4>
        
                    <ul class="params-list">
                        <li class="param">
                                <code class="param-name">map</code>
                                <span class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function" class="crosslink external" target="_blank">Function</a></span>
        
        
                            <div class="param-description">
                                <p>Function to modify the event payload</p>
        
                            </div>
        
                        </li>
                    </ul>
                </div>
        
        
                <div class="example">
                    <h4>Example:</h4>
        
                    <div class="example-content">
                        <pre class="code prettyprint"><code> var eventMapper = new EventMapper(function(payload){
             return payload.x + payload.y
         });
        
         var eventEmitter = new EventEmitter();
        
         eventMapper.subscribe(eventEmitter);
        
         eventMapper.on('name', function(value){
             alert(value);
         });
        
         eventEmitter.emit('name', {x : 1, y : 2}); // alerts 3</code></pre>
        
                    </div>
                </div>
        </div>
    </div>

<div>
    <ul class="nav nav-tabs">
        <li class="active"><a data-toggle="tab" href="#index">Index</a></li>

            <li><a data-toggle="tab" href="#methods">Methods</a></li>
    </ul>

    <div class="tab-content">
        <div id="index" class="tab-pane active">
            <h2 class="off-left">Item Index</h2>

                <div class="index-section methods">
                    <h3>Methods</h3>

                    <ul class="index-list methods">
                            <li class="index-item method">
                                <a href="#" data-tabid="#methods" data-anchor="#method_emit" data-tablink="emit">emit</a>

                            </li>
                            <li class="index-item method">
                                <a href="#" data-tabid="#methods" data-anchor="#method_trigger" data-tablink="trigger">trigger</a>

                            </li>
                    </ul>
                </div>



        </div>

            <div id="methods" class="tab-pane">
                <h2 class="off-left">Methods</h2>

                    <div id="method_emit" class="method item">
                        <h3 class="name"><code>emit</code></h3>
                    
                            <div class="args">
                                <span class="paren">(</span><ul class="args-list inline commas">
                                    <li class="arg">
                                            <code>type</code>
                                    </li>
                                    <li class="arg">
                                            <code>data</code>
                                    </li>
                                </ul><span class="paren">)</span>
                            </div>
                    
                    
                    
                    
                    
                    
                    
                    
                        <div class="meta">
                                    <p>
                                    <!---->
                                    <!--Defined in-->
                                    <!---->
                            <!---->
                            <!--<a href="../files/samsara_events_EventMapper.js.html#l41"><code>samsara&#x2F;events&#x2F;EventMapper.js:41</code></a>-->
                            <!---->
                            </p>
                    
                    
                    
                        </div>
                    
                        <div class="description">
                            <p>Emit mapped event.</p>
                    
                        </div>
                    
                            <div class="params">
                                <h4>Parameters:</h4>
                    
                                <ul class="params-list">
                                    <li class="param">
                                            <code class="param-name">type</code>
                                            <span class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String" class="crosslink external" target="_blank">String</a></span>
                    
                    
                                        <div class="param-description">
                                            <p>Channel name</p>
                    
                                        </div>
                    
                                    </li>
                                    <li class="param">
                                            <code class="param-name">data</code>
                                            <span class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="crosslink external" target="_blank">Object</a></span>
                    
                    
                                        <div class="param-description">
                                            <p>Payload</p>
                    
                                        </div>
                    
                                    </li>
                                </ul>
                            </div>
                    
                    
                    </div>
                    <div id="method_trigger" class="method item">
                        <h3 class="name"><code>trigger</code></h3>
                    
                            <div class="args">
                                <span class="paren">(</span><ul class="args-list inline commas">
                                    <li class="arg">
                                            <code>type</code>
                                    </li>
                                    <li class="arg">
                                            <code>data</code>
                                    </li>
                                </ul><span class="paren">)</span>
                            </div>
                    
                    
                    
                    
                    
                    
                    
                    
                        <div class="meta">
                                    <p>
                                    <!---->
                                    <!--Defined in-->
                                    <!---->
                            <!---->
                            <!--<a href="../files/samsara_events_EventMapper.js.html#l53"><code>samsara&#x2F;events&#x2F;EventMapper.js:53</code></a>-->
                            <!---->
                            </p>
                    
                    
                    
                        </div>
                    
                        <div class="description">
                            <p>Alias of emit.</p>
                    
                        </div>
                    
                            <div class="params">
                                <h4>Parameters:</h4>
                    
                                <ul class="params-list">
                                    <li class="param">
                                            <code class="param-name">type</code>
                                            <span class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String" class="crosslink external" target="_blank">String</a></span>
                    
                    
                                        <div class="param-description">
                                            <p>Channel name</p>
                    
                                        </div>
                    
                                    </li>
                                    <li class="param">
                                            <code class="param-name">data</code>
                                            <span class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="crosslink external" target="_blank">Object</a></span>
                    
                    
                                        <div class="param-description">
                                            <p>Payload</p>
                    
                                        </div>
                    
                                    </li>
                                </ul>
                            </div>
                    
                    
                    </div>
            </div>



    </div>
</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../assets/vendor/jquery/jquery-1.8.2.min.js"></script>
<script src="../assets/vendor/bootstrap/js/bootstrap.js"></script>
<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script src="../assets/js/yuidoc-bootstrap.js"></script>
<script>prettyPrint();</script>
</body>
</html>
