Files
api/docs/api/classes/_rx_index_.apirx.html
T
2018-10-10 18:23:34 +00:00

927 lines
40 KiB
HTML

<!DOCTYPE HTML>
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>ApiRx · Polkadot API Book</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.3">
<link rel="stylesheet" href="../../gitbook/style.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-sunlight-highlighter/sunlight.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
<link rel="next" href="../../rpc-core/" />
<link rel="prev" href="../" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="header">Packages</li>
<li class="chapter " data-level="1.1" data-path="../../">
<a href="../../">
Introduction
</a>
</li>
<li class="chapter " data-level="1.2" data-path="../">
<a href="../">
api
</a>
<ul class="articles">
<li class="chapter active" data-level="1.2.1" data-path="_rx_index_.apirx.html">
<a href="_rx_index_.apirx.html">
ApiRx
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.3" data-path="../../rpc-core/">
<a href="../../rpc-core/">
rpc-core
</a>
<ul class="articles">
<li class="chapter " data-level="1.3.1" data-path="../../rpc-core/classes/_index_.rpc.html">
<a href="../../rpc-core/classes/_index_.rpc.html">
Rpc
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.4" data-path="../../rpc-provider/">
<a href="../../rpc-provider/">
rpc-provider
</a>
<ul class="articles">
<li class="chapter " data-level="1.4.1" data-path="../../rpc-provider/classes/_http_index_.httpprovider.html">
<a href="../../rpc-provider/classes/_http_index_.httpprovider.html">
HttpProvider
</a>
</li>
<li class="chapter " data-level="1.4.2" data-path="../../rpc-provider/classes/_ws_index_.wsprovider.html">
<a href="../../rpc-provider/classes/_ws_index_.wsprovider.html">
WsProvider
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.5" data-path="../../rpc-rx/">
<a href="../../rpc-rx/">
rpc-rx
</a>
<ul class="articles">
<li class="chapter " data-level="1.5.1" data-path="../../rpc-rx/classes/_index_.rxapi.md">
<span>
RpcRx
</a>
</li>
</ul>
</li>
<li class="header">Examples</li>
<li class="chapter " data-level="2.1" data-path="../../examples/">
<a href="../../examples/">
Overview
</a>
</li>
<li class="chapter " data-level="2.2" data-path="../../examples/01_simple_connect/">
<a href="../../examples/01_simple_connect/">
Simple connect
</a>
</li>
<li class="chapter " data-level="2.3" data-path="../../examples/02_listen_to_blocks/">
<a href="../../examples/02_listen_to_blocks/">
Listen to blocks
</a>
</li>
<li class="chapter " data-level="2.4" data-path="../../examples/03_listen_to_balance_change/">
<a href="../../examples/03_listen_to_balance_change/">
Listen to balance change
</a>
</li>
<li class="chapter " data-level="2.5" data-path="../../examples/04_generate_account/">
<a href="../../examples/04_generate_account/">
Generate Accounts
</a>
</li>
<li class="chapter " data-level="2.6" data-path="../../examples/05_read_storage/">
<a href="../../examples/05_read_storage/">
Read Storage
</a>
</li>
<li class="chapter " data-level="2.7" data-path="../../examples/06_craft_extrinsic/">
<a href="../../examples/06_craft_extrinsic/">
Craft Extrinsic
</a>
</li>
<li class="chapter " data-level="2.8" data-path="../../examples/07_transfer_dots/">
<a href="../../examples/07_transfer_dots/">
Transfer DOTs
</a>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="../.." >ApiRx</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<h1 id="type-parameters">Type parameters</h1>
<h4 id="eventtypes----string--symbol">EventTypes : <code>string</code> | <code>symbol</code></h4>
<h1 id="hierarchy">Hierarchy</h1>
<p> <code>EventEmitter</code></p>
<p><strong>&#x21B3; ApiRx</strong></p>
<h1 id="implements">Implements</h1>
<ul>
<li><a href="../interfaces/_rx_types_d_.rxapiinterface.md">RxApiInterface</a></li>
</ul>
<h1 id="constructors">Constructors</h1>
<p><a id="constructor"></a></p>
<h2 id="constructor">constructor</h2>
<p>&#x2295; <strong>new ApiRx</strong>(wsProvider?: <em><code>WsProvider</code></em>): <a href="_rx_index_.apirx.html">ApiRx</a></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7180f89/packages/api/src/rx/index.ts#L59" target="_blank">rx/index.ts:59</a></em></p>
<p><em><strong>example</strong></em>: </p>
<pre><code class="lang-javascript"><div class="sunlight-container sunlight-theme-gitbook"><div class="sunlight-code-container"><pre class="sunlight-highlight-javascript sunlight-highlighted"><span class="sunlight-javascript"><span class="sunlight-reservedWord">import</span>&#xA0;<span class="sunlight-ident">Api</span>&#xA0;<span class="sunlight-ident">from</span>&#xA0;<span class="sunlight-string">&apos;@polkadot/api/rx&apos;</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-keyword">new</span>&#xA0;<span class="sunlight-ident">Api</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">)</span><span class="sunlight-operator">.</span><span class="sunlight-ident">isReady</span><span class="sunlight-operator">.</span><span class="sunlight-ident">subscribe</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">api</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;<span class="sunlight-ident">api</span><span class="sunlight-operator">.</span><span class="sunlight-ident">rpc</span><span class="sunlight-operator">.</span><span class="sunlight-ident">newHead</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">)</span><span class="sunlight-operator">.</span><span class="sunlight-ident">subscribe</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">header</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">log</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">`</span><span class="sunlight-keyword">new</span>&#xA0;<span class="sunlight-ident">block</span>&#xA0;<span class="sunlight-punctuation">#</span><span class="sunlight-ident">$</span><span class="sunlight-punctuation">{</span><span class="sunlight-ident">header</span><span class="sunlight-operator">.</span><span class="sunlight-ident">blockNumber</span><span class="sunlight-operator">.</span><span class="sunlight-ident">toNumber</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">`</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
&#xA0;&#xA0;<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
</span></pre></div></div></code></pre>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Optional</code> wsProvider</td>
<td><code>WsProvider</code></td>
<td>An optional WebSocket provider from rpc-provider/ws. If not specified, it will default to connecting to the localhost with the default port</td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <a href="_rx_index_.apirx.html">ApiRx</a></p>
<hr>
<h1 id="properties">Properties</h1>
<p><a id="isready"></a></p>
<h2 id="isready">isReady</h2>
<p><strong>&#x25CF; isReady</strong>: <em><code>Observable</code>&lt;<a href="_rx_index_.apirx.html">ApiRx</a>&gt;</em></p>
<p><em>Implementation of <a href="../interfaces/_rx_types_d_.rxapiinterface.md">RxApiInterface</a>.<a href="../interfaces/_rx_types_d_.rxapiinterface.md#isready">isReady</a></em></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7180f89/packages/api/src/rx/index.ts#L39" target="_blank">rx/index.ts:39</a></em></p>
<hr>
<p><a id="prefixed"></a></p>
<h2 id="static-prefixed"><code>&lt;Static&gt;</code> prefixed</h2>
<p><strong>&#x25CF; prefixed</strong>: <em> <code>string</code> | <code>boolean</code>
</em></p>
<p><em>Inherited from EventEmitter.prefixed</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:6</em></p>
<hr>
<h1 id="accessors">Accessors</h1>
<p><a id="genesishash"></a></p>
<h2 id="genesishash">genesisHash</h2>
<p>getgenesisHash(): <code>Hash</code></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7180f89/packages/api/src/rx/index.ts#L94" target="_blank">rx/index.ts:94</a></em></p>
<p><em><strong>description</strong></em>: Contains the genesis Hash of the attached chain. Apart from being useful to determine the actual chain, it can also be used to sign immortal transactions.</p>
<p><strong>Returns:</strong> <code>Hash</code></p>
<hr>
<p><a id="isconnected"></a></p>
<h2 id="isconnected">isConnected</h2>
<p>getisConnected(): <code>Observable</code>&lt;<code>boolean</code>&gt;</p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7180f89/packages/api/src/rx/index.ts#L87" target="_blank">rx/index.ts:87</a></em></p>
<p><em><strong>description</strong></em>: Observable that carries the connected state for the provider. Results in a boolean flag that is true/false based on the connectivity.</p>
<p><strong>Returns:</strong> <code>Observable</code>&lt;<code>boolean</code>&gt;</p>
<hr>
<p><a id="rpc"></a></p>
<h2 id="rpc">rpc</h2>
<p>getrpc(): <code>RpcRx</code></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7180f89/packages/api/src/rx/index.ts#L113" target="_blank">rx/index.ts:113</a></em></p>
<p><em><strong>description</strong></em>: Contains all the raw rpc sections and their subsequent methods in the API as defined by the jsonrpc interface definitions.</p>
<p><em><strong>example</strong></em>: </p>
<pre><code class="lang-javascript"><div class="sunlight-container sunlight-theme-gitbook"><div class="sunlight-code-container"><pre class="sunlight-highlight-javascript sunlight-highlighted"><span class="sunlight-javascript"><span class="sunlight-ident">api</span><span class="sunlight-operator">.</span><span class="sunlight-ident">rpc</span><span class="sunlight-operator">.</span><span class="sunlight-ident">chain</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">newHead</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">)</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">subscribe</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">header</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">log</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;new&#xA0;header&apos;</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-ident">header</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
&#xA0;&#xA0;<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
</span></pre></div></div></code></pre>
<p><strong>Returns:</strong> <code>RpcRx</code></p>
<hr>
<p><a id="runtimemetadata"></a></p>
<h2 id="runtimemetadata">runtimeMetadata</h2>
<p>getruntimeMetadata(): <code>RuntimeMetadata</code></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7180f89/packages/api/src/rx/index.ts#L120" target="_blank">rx/index.ts:120</a></em></p>
<p><em><strong>description</strong></em>: Yields the current attached runtime metadata. Generally this is only used to construct extrinsics &amp; storage, but is useful for current runtime inspection.</p>
<p><strong>Returns:</strong> <code>RuntimeMetadata</code></p>
<hr>
<p><a id="runtimeversion"></a></p>
<h2 id="runtimeversion">runtimeVersion</h2>
<p>getruntimeVersion(): <code>RuntimeVersion</code></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7180f89/packages/api/src/rx/index.ts#L129" target="_blank">rx/index.ts:129</a></em></p>
<p><em><strong>description</strong></em>: Contains the version information for the current runtime.</p>
<p><strong>Returns:</strong> <code>RuntimeVersion</code></p>
<hr>
<p><a id="st"></a></p>
<h2 id="st">st</h2>
<p>getst(): <a href="../interfaces/_rx_types_d_.queryablestorage.md">QueryableStorage</a></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7180f89/packages/api/src/rx/index.ts#L148" target="_blank">rx/index.ts:148</a></em></p>
<p><em><strong>description</strong></em>: Contains all the chain state modules and their subsequent methods in the API. These are attached dynamically from the runtime metadata.</p>
<p><em><strong>example</strong></em>: </p>
<pre><code class="lang-javascript"><div class="sunlight-container sunlight-theme-gitbook"><div class="sunlight-code-container"><pre class="sunlight-highlight-javascript sunlight-highlighted"><span class="sunlight-javascript"><span class="sunlight-ident">api</span><span class="sunlight-operator">.</span><span class="sunlight-ident">st</span><span class="sunlight-operator">.</span><span class="sunlight-ident">balances</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">freeBalance</span><span class="sunlight-punctuation">(</span><span class="sunlight-operator">&lt;</span><span class="sunlight-ident">accountId</span><span class="sunlight-operator">&gt;</span><span class="sunlight-punctuation">)</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">subscribe</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">balance</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">log</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;new&#xA0;balance&apos;</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-ident">balance</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
&#xA0;&#xA0;<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
</span></pre></div></div></code></pre>
<p><strong>Returns:</strong> <a href="../interfaces/_rx_types_d_.queryablestorage.md">QueryableStorage</a></p>
<hr>
<p><a id="tx"></a></p>
<h2 id="tx">tx</h2>
<p>gettx(): <a href="../interfaces/_rx_types_d_.submittableextrinsics.md">SubmittableExtrinsics</a></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7180f89/packages/api/src/rx/index.ts#L169" target="_blank">rx/index.ts:169</a></em></p>
<p><em><strong>description</strong></em>: Contains all the extrinsic modules and their subsequent methods in the API. It allows for the construction of transactions and the submission thereof. These are attached dynamically from the runtime metadata.</p>
<p><em><strong>example</strong></em>: </p>
<pre><code class="lang-javascript"><div class="sunlight-container sunlight-theme-gitbook"><div class="sunlight-code-container"><pre class="sunlight-highlight-javascript sunlight-highlighted"><span class="sunlight-javascript"><span class="sunlight-ident">api</span><span class="sunlight-operator">.</span><span class="sunlight-ident">tx</span><span class="sunlight-operator">.</span><span class="sunlight-ident">balances</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">transfer</span><span class="sunlight-punctuation">(</span><span class="sunlight-operator">&lt;</span><span class="sunlight-ident">recipientId</span><span class="sunlight-operator">&gt;</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-operator">&lt;</span><span class="sunlight-ident">balance</span><span class="sunlight-operator">&gt;</span><span class="sunlight-punctuation">)</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">sign</span><span class="sunlight-punctuation">(</span><span class="sunlight-operator">&lt;</span><span class="sunlight-ident">keyPair</span><span class="sunlight-operator">&gt;</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-operator">&lt;</span><span class="sunlight-ident">accountNonce</span><span class="sunlight-operator">&gt;</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-operator">&lt;</span><span class="sunlight-ident">blockHash</span>&#xA0;<span class="sunlight-punctuation">(</span><span class="sunlight-ident">optional</span><span class="sunlight-punctuation">)</span><span class="sunlight-operator">&gt;</span><span class="sunlight-punctuation">)</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">send</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">)</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">subscribe</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">status</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">log</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;tx&#xA0;status&apos;</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-ident">status</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
&#xA0;&#xA0;<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
</span></pre></div></div></code></pre>
<p><strong>Returns:</strong> <a href="../interfaces/_rx_types_d_.submittableextrinsics.md">SubmittableExtrinsics</a></p>
<hr>
<h1 id="methods">Methods</h1>
<p><a id="addlistener"></a></p>
<h2 id="addlistener">addListener</h2>
<p>&#x25B8; <strong>addListener</strong>(event: <em><code>EventTypes</code></em>, fn: <em><code>ListenerFn</code></em>, context?: <em><code>any</code></em>): <code>this</code></p>
<p><em>Inherited from EventEmitter.addListener</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:33</em></p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>event</td>
<td><code>EventTypes</code></td>
</tr>
<tr>
<td>fn</td>
<td><code>ListenerFn</code></td>
</tr>
<tr>
<td><code>Optional</code> context</td>
<td><code>any</code></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>this</code></p>
<hr>
<p><a id="emit"></a></p>
<h2 id="emit">emit</h2>
<p>&#x25B8; <strong>emit</strong>(event: <em><code>EventTypes</code></em>, ...args: <em><code>Array</code>&lt;<code>any</code>&gt;</em>): <code>boolean</code></p>
<p><em>Inherited from EventEmitter.emit</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:27</em></p>
<p>Calls each of the listeners registered for a given event.</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>event</td>
<td><code>EventTypes</code></td>
</tr>
<tr>
<td><code>Rest</code> args</td>
<td><code>Array</code>&lt;<code>any</code>&gt;</td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>boolean</code></p>
<hr>
<p><a id="eventnames"></a></p>
<h2 id="eventnames">eventNames</h2>
<p>&#x25B8; <strong>eventNames</strong>(): <code>Array</code>&lt;<code>EventTypes</code>&gt;</p>
<p><em>Inherited from EventEmitter.eventNames</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:12</em></p>
<p>Return an array listing the events for which the emitter has registered listeners.</p>
<p><strong>Returns:</strong> <code>Array</code>&lt;<code>EventTypes</code>&gt;</p>
<hr>
<p><a id="listenercount"></a></p>
<h2 id="listenercount">listenerCount</h2>
<p>&#x25B8; <strong>listenerCount</strong>(event: <em><code>EventTypes</code></em>): <code>number</code></p>
<p><em>Inherited from EventEmitter.listenerCount</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:22</em></p>
<p>Return the number of listeners listening to a given event.</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>event</td>
<td><code>EventTypes</code></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>number</code></p>
<hr>
<p><a id="listeners"></a></p>
<h2 id="listeners">listeners</h2>
<p>&#x25B8; <strong>listeners</strong>(event: <em><code>EventTypes</code></em>): <code>Array</code>&lt;<code>ListenerFn</code>&gt;</p>
<p><em>Inherited from EventEmitter.listeners</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:17</em></p>
<p>Return the listeners registered for a given event.</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>event</td>
<td><code>EventTypes</code></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>Array</code>&lt;<code>ListenerFn</code>&gt;</p>
<hr>
<p><a id="off"></a></p>
<h2 id="off">off</h2>
<p>&#x25B8; <strong>off</strong>(event: <em><code>EventTypes</code></em>, fn?: <em><a href="../interfaces/_rx_index_.apirx.eventemitter.listenerfn.md">ListenerFn</a></em>, context?: <em><code>any</code></em>, once?: <em> <code>undefined</code> | <code>false</code> | <code>true</code></em>): <code>this</code></p>
<p><em>Inherited from EventEmitter.off</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:44</em></p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>event</td>
<td><code>EventTypes</code></td>
</tr>
<tr>
<td><code>Optional</code> fn</td>
<td><a href="../interfaces/_rx_index_.apirx.eventemitter.listenerfn.md">ListenerFn</a></td>
</tr>
<tr>
<td><code>Optional</code> context</td>
<td><code>any</code></td>
</tr>
<tr>
<td><code>Optional</code> once</td>
<td><code>undefined</code> | <code>false</code> | <code>true</code></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>this</code></p>
<hr>
<p><a id="on"></a></p>
<h2 id="on">on</h2>
<p>&#x25B8; <strong>on</strong>(event: <em><code>EventTypes</code></em>, fn: <em><code>ListenerFn</code></em>, context?: <em><code>any</code></em>): <code>this</code></p>
<p><em>Inherited from EventEmitter.on</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:32</em></p>
<p>Add a listener for a given event.</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>event</td>
<td><code>EventTypes</code></td>
</tr>
<tr>
<td>fn</td>
<td><code>ListenerFn</code></td>
</tr>
<tr>
<td><code>Optional</code> context</td>
<td><code>any</code></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>this</code></p>
<hr>
<p><a id="once"></a></p>
<h2 id="once">once</h2>
<p>&#x25B8; <strong>once</strong>(event: <em><code>EventTypes</code></em>, fn: <em><code>ListenerFn</code></em>, context?: <em><code>any</code></em>): <code>this</code></p>
<p><em>Inherited from EventEmitter.once</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:38</em></p>
<p>Add a one-time listener for a given event.</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>event</td>
<td><code>EventTypes</code></td>
</tr>
<tr>
<td>fn</td>
<td><code>ListenerFn</code></td>
</tr>
<tr>
<td><code>Optional</code> context</td>
<td><code>any</code></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>this</code></p>
<hr>
<p><a id="removealllisteners"></a></p>
<h2 id="removealllisteners">removeAllListeners</h2>
<p>&#x25B8; <strong>removeAllListeners</strong>(event?: <em><a href="">EventTypes</a></em>): <code>this</code></p>
<p><em>Inherited from EventEmitter.removeAllListeners</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:49</em></p>
<p>Remove all listeners, or those of the specified event.</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Optional</code> event</td>
<td><a href="">EventTypes</a></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>this</code></p>
<hr>
<p><a id="removelistener"></a></p>
<h2 id="removelistener">removeListener</h2>
<p>&#x25B8; <strong>removeListener</strong>(event: <em><code>EventTypes</code></em>, fn?: <em><a href="../interfaces/_rx_index_.apirx.eventemitter.listenerfn.md">ListenerFn</a></em>, context?: <em><code>any</code></em>, once?: <em> <code>undefined</code> | <code>false</code> | <code>true</code></em>): <code>this</code></p>
<p><em>Inherited from EventEmitter.removeListener</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:43</em></p>
<p>Remove the listeners of a given event.</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>event</td>
<td><code>EventTypes</code></td>
</tr>
<tr>
<td><code>Optional</code> fn</td>
<td><a href="../interfaces/_rx_index_.apirx.eventemitter.listenerfn.md">ListenerFn</a></td>
</tr>
<tr>
<td><code>Optional</code> context</td>
<td><code>any</code></td>
</tr>
<tr>
<td><code>Optional</code> once</td>
<td><code>undefined</code> | <code>false</code> | <code>true</code></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>this</code></p>
<hr>
<p><a id="create"></a></p>
<h2 id="static-create"><code>&lt;Static&gt;</code> create</h2>
<p>&#x25B8; <strong>create</strong>(wsProvider?: <em><code>WsProvider</code></em>): <code>Observable</code>&lt;<a href="_rx_index_.apirx.html">ApiRx</a>&gt;</p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7180f89/packages/api/src/rx/index.ts#L57" target="_blank">rx/index.ts:57</a></em></p>
<p><em><strong>description</strong></em>: Creates an ApiRx instance using the supplied provider. Returns an Observable containing the actual Api instance.</p>
<p><em><strong>example</strong></em>: </p>
<pre><code class="lang-javascript"><div class="sunlight-container sunlight-theme-gitbook"><div class="sunlight-code-container"><pre class="sunlight-highlight-javascript sunlight-highlighted"><span class="sunlight-javascript"><span class="sunlight-reservedWord">import</span>&#xA0;<span class="sunlight-ident">Api</span>&#xA0;<span class="sunlight-ident">from</span>&#xA0;<span class="sunlight-string">&apos;@polkadot/api/rx&apos;</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-ident">Api</span><span class="sunlight-operator">.</span><span class="sunlight-ident">create</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">)</span><span class="sunlight-operator">.</span><span class="sunlight-ident">subscribe</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">api</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;<span class="sunlight-ident">api</span><span class="sunlight-operator">.</span><span class="sunlight-ident">st</span><span class="sunlight-operator">.</span><span class="sunlight-ident">timestamp</span><span class="sunlight-operator">.</span><span class="sunlight-ident">now</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">timestamp</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">log</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">`</span><span class="sunlight-ident">lastest</span>&#xA0;<span class="sunlight-ident">block</span>&#xA0;<span class="sunlight-ident">timestamp</span>&#xA0;<span class="sunlight-ident">$</span><span class="sunlight-punctuation">{</span><span class="sunlight-ident">timestamp</span><span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">`</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
&#xA0;&#xA0;<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
</span></pre></div></div></code></pre>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Optional</code> wsProvider</td>
<td><code>WsProvider</code></td>
<td>Optional WebSocket provider that is passed to the class contructor</td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>Observable</code>&lt;<a href="_rx_index_.apirx.html">ApiRx</a>&gt;</p>
<hr>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="../" class="navigation navigation-prev " aria-label="Previous page: api">
<i class="fa fa-angle-left"></i>
</a>
<a href="../../rpc-core/" class="navigation navigation-next " aria-label="Next page: rpc-core">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"ApiRx","level":"1.2.1","depth":2,"next":{"title":"rpc-core","level":"1.3","depth":1,"path":"rpc-core/README.md","ref":"rpc-core/README.md","articles":[{"title":"Rpc","level":"1.3.1","depth":2,"path":"rpc-core/classes/_index_.rpc.md","ref":"rpc-core/classes/_index_.rpc.md","articles":[]}]},"previous":{"title":"api","level":"1.2","depth":1,"path":"api/README.md","ref":"api/README.md","articles":[{"title":"ApiRx","level":"1.2.1","depth":2,"path":"api/classes/_rx_index_.apirx.md","ref":"api/classes/_rx_index_.apirx.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["include-codeblock","mermaid-gb3","-highlight","sunlight-highlighter"],"root":"docs","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"sunlight-highlighter":{"theme":"gitbook","lineNumbers":false},"include-codeblock":{"check":false,"edit":false,"lang":"","fixlang":false,"template":"default","theme":"chrome","unindent":false},"mermaid-gb3":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Polkadot API Book","gitbook":">=2.4.0"},"file":{"path":"api/classes/_rx_index_.apirx.md","mtime":"2018-10-10T18:21:51.937Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-10T18:23:26.992Z"},"basePath":"../..","book":{"language":""}});
});
</script>
</div>
<script src="../../gitbook/gitbook.js"></script>
<script src="../../gitbook/theme.js"></script>
<script src="../../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
<script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
<script src="../../gitbook/gitbook-plugin-search/search.js"></script>
<script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
<script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
<script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
<script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
<script src="../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
</body>
</html>