UNPKG

meteor-sdk

Version:

The aim of this library is to simplify the process of working with meteor server over DDP protocol using external JS environments

2,660 lines (1,065 loc) 54.6 kB
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>SimpleDDP Docs</title> <meta name="description" content="SimpleDDP Docs" /> <meta name="keywords" content="ddp, simpleddp, websocket, meteor" /> <meta name="keyword" content="ddp, simpleddp, websocket, meteor" /> <meta property="og:title" content="SimpleDDP Docs"/> <meta property="og:type" content="website"/> <meta property="og:image" content="https://github.com/Gregivy/simpleddp/raw/2.x.x/simpleddp.png"/> <meta property="og:site_name" content="SimpleDDP Docs"/> <meta property="og:url" content=""/> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="scripts/prettify/prettify.js"></script> <script src="scripts/prettify/lang-css.js"></script> <script src="scripts/jquery.min.js"></script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link href="https://fonts.googleapis.com/css?family=Libre+Franklin:400,700" rel="stylesheet"> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/bootstrap.min.css"> <link type="text/css" rel="stylesheet" href="styles/main.css"> <script> var config = {"monospaceLinks":false,"cleverLinks":false,"applicationName":"SimpleDDP","disqus":"","googleAnalytics":"","openGraph":{"title":"SimpleDDP Docs","type":"website","image":"https://github.com/Gregivy/simpleddp/raw/2.x.x/simpleddp.png","site_name":"SimpleDDP Docs","url":""},"meta":{"title":"SimpleDDP Docs","description":"SimpleDDP Docs","keyword":"ddp, simpleddp, websocket, meteor"},"linenums":true,"default":{}}; </script> </head> <body> <div id="wrap" class="clearfix"> <div class="navigation"> <h3 class="applicationName"><a href="index.html">SimpleDDP</a></h3> <button id="menuToggle" class="btn btn-link btn-lg menu-toggle"> <span class="glyphicon glyphicon-menu-hamburger"></span> </button> <div class="search"> <input id="search" type="text" class="form-control input-md" placeholder="Search..."> </div> <ul class="list"> <li class="item" data-name="ddpCollection"> <span class="title "> <a href="ddpCollection.html">ddpCollection</a> </span> <ul class="members itemMembers"> </ul> <ul class="typedefs itemMembers"> </ul> <ul class="typedefs itemMembers"> </ul> <ul class="methods itemMembers"> <span class="subtitle">Methods</span> <li class="parent " data-name="ddpCollection#exportData"><a href="ddpCollection.html#exportData">exportData</a></li> <li class="parent " data-name="ddpCollection#fetch"><a href="ddpCollection.html#fetch">fetch</a></li> <li class="parent " data-name="ddpCollection#filter"><a href="ddpCollection.html#filter">filter</a></li> <li class="parent " data-name="ddpCollection#importData"><a href="ddpCollection.html#importData">importData</a></li> <li class="parent " data-name="ddpCollection#onChange"><a href="ddpCollection.html#onChange">onChange</a></li> <li class="parent " data-name="ddpCollection#reactive"><a href="ddpCollection.html#reactive">reactive</a></li> </ul> <ul class="events itemMembers"> </ul> </li> <li class="item" data-name="ddpEventListener"> <span class="title "> <a href="ddpEventListener.html">ddpEventListener</a> </span> <ul class="members itemMembers"> </ul> <ul class="typedefs itemMembers"> </ul> <ul class="typedefs itemMembers"> </ul> <ul class="methods itemMembers"> <span class="subtitle">Methods</span> <li class="parent " data-name="ddpEventListener#start"><a href="ddpEventListener.html#start">start</a></li> <li class="parent " data-name="ddpEventListener#stop"><a href="ddpEventListener.html#stop">stop</a></li> </ul> <ul class="events itemMembers"> </ul> </li> <li class="item" data-name="ddpOnChange"> <span class="title "> <a href="ddpOnChange.html">ddpOnChange</a> </span> <ul class="members itemMembers"> </ul> <ul class="typedefs itemMembers"> </ul> <ul class="typedefs itemMembers"> </ul> <ul class="methods itemMembers"> <span class="subtitle">Methods</span> <li class="parent " data-name="ddpOnChange#start"><a href="ddpOnChange.html#start">start</a></li> <li class="parent " data-name="ddpOnChange#stop"><a href="ddpOnChange.html#stop">stop</a></li> </ul> <ul class="events itemMembers"> </ul> </li> <li class="item" data-name="ddpReactiveCollection"> <span class="title "> <a href="ddpReactiveCollection.html">ddpReactiveCollection</a> </span> <ul class="members itemMembers"> </ul> <ul class="typedefs itemMembers"> </ul> <ul class="typedefs itemMembers"> </ul> <ul class="methods itemMembers"> <span class="subtitle">Methods</span> <li class="parent " data-name="ddpReactiveCollection#_updateReactiveObjects"><a href="ddpReactiveCollection.html#_updateReactiveObjects">_updateReactiveObjects</a></li> <li class="parent " data-name="ddpReactiveCollection#count"><a href="ddpReactiveCollection.html#count">count</a></li> <li class="parent " data-name="ddpReactiveCollection#data"><a href="ddpReactiveCollection.html#data">data</a></li> <li class="parent " data-name="ddpReactiveCollection#map"><a href="ddpReactiveCollection.html#map">map</a></li> <li class="parent " data-name="ddpReactiveCollection#onChange"><a href="ddpReactiveCollection.html#onChange">onChange</a></li> <li class="parent " data-name="ddpReactiveCollection#one"><a href="ddpReactiveCollection.html#one">one</a></li> <li class="parent " data-name="ddpReactiveCollection#reduce"><a href="ddpReactiveCollection.html#reduce">reduce</a></li> <li class="parent " data-name="ddpReactiveCollection#settings"><a href="ddpReactiveCollection.html#settings">settings</a></li> <li class="parent " data-name="ddpReactiveCollection#sort"><a href="ddpReactiveCollection.html#sort">sort</a></li> <li class="parent " data-name="ddpReactiveCollection#start"><a href="ddpReactiveCollection.html#start">start</a></li> <li class="parent " data-name="ddpReactiveCollection#stop"><a href="ddpReactiveCollection.html#stop">stop</a></li> </ul> <ul class="events itemMembers"> </ul> </li> <li class="item" data-name="ddpReactiveDocument"> <span class="title "> <a href="ddpReactiveDocument.html">ddpReactiveDocument</a> </span> <ul class="members itemMembers"> </ul> <ul class="typedefs itemMembers"> </ul> <ul class="typedefs itemMembers"> </ul> <ul class="methods itemMembers"> <span class="subtitle">Methods</span> <li class="parent " data-name="ddpReactiveDocument#data"><a href="ddpReactiveDocument.html#data">data</a></li> <li class="parent " data-name="ddpReactiveDocument#onChange"><a href="ddpReactiveDocument.html#onChange">onChange</a></li> <li class="parent " data-name="ddpReactiveDocument#settings"><a href="ddpReactiveDocument.html#settings">settings</a></li> <li class="parent " data-name="ddpReactiveDocument#start"><a href="ddpReactiveDocument.html#start">start</a></li> <li class="parent " data-name="ddpReactiveDocument#stop"><a href="ddpReactiveDocument.html#stop">stop</a></li> </ul> <ul class="events itemMembers"> </ul> </li> <li class="item" data-name="ddpReducer"> <span class="title "> <a href="ddpReducer.html">ddpReducer</a> </span> <ul class="members itemMembers"> </ul> <ul class="typedefs itemMembers"> </ul> <ul class="typedefs itemMembers"> </ul> <ul class="methods itemMembers"> <span class="subtitle">Methods</span> <li class="parent " data-name="ddpReducer#data"><a href="ddpReducer.html#data">data</a></li> <li class="parent " data-name="ddpReducer#doReduce"><a href="ddpReducer.html#doReduce">doReduce</a></li> <li class="parent " data-name="ddpReducer#onChange"><a href="ddpReducer.html#onChange">onChange</a></li> <li class="parent " data-name="ddpReducer#start"><a href="ddpReducer.html#start">start</a></li> <li class="parent " data-name="ddpReducer#stop"><a href="ddpReducer.html#stop">stop</a></li> </ul> <ul class="events itemMembers"> </ul> </li> <li class="item" data-name="ddpSubscription"> <span class="title "> <a href="ddpSubscription.html">ddpSubscription</a> </span> <ul class="members itemMembers"> </ul> <ul class="typedefs itemMembers"> </ul> <ul class="typedefs itemMembers"> </ul> <ul class="methods itemMembers"> <span class="subtitle">Methods</span> <li class="parent " data-name="ddpSubscription#isOn"><a href="ddpSubscription.html#isOn">isOn</a></li> <li class="parent " data-name="ddpSubscription#isReady"><a href="ddpSubscription.html#isReady">isReady</a></li> <li class="parent " data-name="ddpSubscription#isStopped"><a href="ddpSubscription.html#isStopped">isStopped</a></li> <li class="parent " data-name="ddpSubscription#nosub"><a href="ddpSubscription.html#nosub">nosub</a></li> <li class="parent " data-name="ddpSubscription#onNosub"><a href="ddpSubscription.html#onNosub">onNosub</a></li> <li class="parent " data-name="ddpSubscription#onReady"><a href="ddpSubscription.html#onReady">onReady</a></li> <li class="parent " data-name="ddpSubscription#ready"><a href="ddpSubscription.html#ready">ready</a></li> <li class="parent " data-name="ddpSubscription#remove"><a href="ddpSubscription.html#remove">remove</a></li> <li class="parent " data-name="ddpSubscription#restart"><a href="ddpSubscription.html#restart">restart</a></li> <li class="parent " data-name="ddpSubscription#start"><a href="ddpSubscription.html#start">start</a></li> <li class="parent " data-name="ddpSubscription#stop"><a href="ddpSubscription.html#stop">stop</a></li> </ul> <ul class="events itemMembers"> </ul> </li> <li class="item" data-name="DDPClient"> <span class="title "> <a href="simpleDDP.html">DDPClient</a> </span> <ul class="members itemMembers"> <span class="subtitle">Members</span> <li class="parent " data-name="DDPClient#collections"><a href="simpleDDP.html#collections">collections</a></li> <li class="parent " data-name="DDPClient#connected"><a href="simpleDDP.html#connected">connected</a></li> </ul> <ul class="typedefs itemMembers"> </ul> <ul class="typedefs itemMembers"> </ul> <ul class="methods itemMembers"> <span class="subtitle">Methods</span> <li class="parent " data-name="DDPClient#apply"><a href="simpleDDP.html#apply">apply</a></li> <li class="parent " data-name="DDPClient#call"><a href="simpleDDP.html#call">call</a></li> <li class="parent " data-name="DDPClient#clearData"><a href="simpleDDP.html#clearData">clearData</a></li> <li class="parent " data-name="DDPClient#collection"><a href="simpleDDP.html#collection">collection</a></li> <li class="parent " data-name="DDPClient#connect"><a href="simpleDDP.html#connect">connect</a></li> <li class="parent " data-name="DDPClient#disconnect"><a href="simpleDDP.html#disconnect">disconnect</a></li> <li class="parent " data-name="DDPClient#exportData"><a href="simpleDDP.html#exportData">exportData</a></li> <li class="parent " data-name="DDPClient#importData"><a href="simpleDDP.html#importData">importData</a></li> <li class="parent " data-name="DDPClient#markAsReady"><a href="simpleDDP.html#markAsReady">markAsReady</a></li> <li class="parent " data-name="DDPClient#on"><a href="simpleDDP.html#on">on</a></li> <li class="parent " data-name="DDPClient#stopChangeListeners"><a href="simpleDDP.html#stopChangeListeners">stopChangeListeners</a></li> <li class="parent " data-name="DDPClient#sub"><a href="simpleDDP.html#sub">sub</a></li> <li class="parent " data-name="DDPClient#subscribe"><a href="simpleDDP.html#subscribe">subscribe</a></li> </ul> <ul class="events itemMembers"> </ul> </li> </ul> </div> <div class="main"> <h1 class="page-title" data-filename="DDPClient.html">Class: DDPClient</h1> <section> <header> <div class="header content-size"> <h2>DDPClient </h2> <div class="class-description"><p>Creates an instance of DDPClient class. After being constructed, the instance will establish a connection with the DDP server and will try to maintain it open.</p></div> </div> </header> <article class="content-size"> <div class="container-overview"> <dt> <div class="nameContainer"> <h4 class="name" id="simpleDDP"> <a class="share-icon" href="#simpleDDP"><span class="glyphicon glyphicon-link"></span></a> <span class=""> new DDPClient </span> <span class="signature">(options, <span class="optional">plugins</span>)</span><span class="type-signature"><a href="simpleDDP.html">DDPClient</a></span> </h4> </div> </dt> <dd> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>options</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last"> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>endpoint</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="default"> </td> <td class="description last"> <p>The location of the websocket server. Its format depends on the type of socket you are using. If you are using https connection you have to use wss:// protocol.</p></td> </tr> <tr> <td class="name"><code>SocketConstructor</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="default"> </td> <td class="description last"> <p>The constructor function that will be used to construct the socket. Meteor (currently the only DDP server available) supports websockets and SockJS sockets. So, practically speaking, this means that on the browser you can use either the browser's native WebSocket constructor or the SockJS constructor provided by the SockJS library. On the server you can use whichever library implements the websocket protocol (e.g. faye-websocket).</p></td> </tr> <tr> <td class="name"><code>autoConnect</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="default"> true </td> <td class="description last"> <span class="optional">optional</span> <p>Whether to establish the connection to the server upon instantiation. When false, one can manually establish the connection with the connect method.</p></td> </tr> <tr> <td class="name"><code>autoReconnect</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="default"> true </td> <td class="description last"> <span class="optional">optional</span> <p>Whether to try to reconnect to the server when the socket connection closes, unless the closing was initiated by a call to the disconnect method.</p></td> </tr> <tr> <td class="name"><code>reconnectInterval</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="default"> 1000 </td> <td class="description last"> <span class="optional">optional</span> <p>The interval in ms between reconnection attempts.</p></td> </tr> <tr> <td class="name"><code>clearDataOnReconnection</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="default"> true </td> <td class="description last"> <span class="optional">optional</span> <p>Whether to clear all collections data after a reconnection. This invokes fake <code>removed</code> messages on every document.</p></td> </tr> <tr> <td class="name"><code>maxTimeout</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="default"> </td> <td class="description last"> <span class="optional">optional</span> <p>Maximum wait for a response from the server to the method call. Default no maxTimeout.</p></td> </tr> </tbody> </table> </td> </tr> <tr> <td class="name"><code>plugins</code></td> <td class="type"> <span class="param-type">Array</span> </td> <td class="description last"> <span class="optional">optional</span> <p>Array of plugins.</p></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-version">Version:</dt> <dd class="tag-version"><ul class="dummy"><li>2.2.4</li></ul></dd> </dl> <h5>Returns:</h5> <table class="params"> <thead> <tr> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="type"> <a href="simpleDDP.html">DDPClient</a> </td> <td class="description last"><ul> <li>A new DDPClient instance.</li> </ul></td> </tr> </tbody> </table> <h5>Example</h5> <pre class="prettyprint"><code>var opts = { endpoint: "ws://someserver.com/websocket", SocketConstructor: WebSocket, reconnectInterval: 5000 }; var server = new DDPClient(opts);</code></pre> </dd> </div> <h3 class="subsection-title">Members</h3> <dl class="list-members"> <dt> <div class="nameContainer"> <h4 class="name" id="collections"> <a class="share-icon" href="#collections"><span class="glyphicon glyphicon-link"></span></a> <span class="">collections</span> <span class="type-signature type">Object</span> </h4> </div> </dt> <dd> <div class="description"> <p>All collections data recieved from server.</p> </div> <dl class="details"> </dl> </dd> <dt> <div class="nameContainer"> <h4 class="name" id="connected"> <a class="share-icon" href="#connected"><span class="glyphicon glyphicon-link"></span></a> <span class="">connected</span> <span class="type-signature type">Boolean</span> </h4> </div> </dt> <dd> <div class="description"> <p>Whether the client is connected to server.</p> </div> <dl class="details"> </dl> </dd> </dl> <h3 class="subsection-title">Methods</h3> <dl class="list-methods"> <dt> <div class="nameContainer"> <h4 class="name" id="apply"> <a class="share-icon" href="#apply"><span class="glyphicon glyphicon-link"></span></a> <span class=""> apply </span> <span class="signature">(method, <span class="optional">arguments</span>, <span class="optional">atBeginning</span>)</span><span class="type-signature">Promise</span> </h4> </div> </dt> <dd> <div class="description"> <p>Calls a remote method with arguments passed in array.</p> </div> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>method</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="default"> </td> <td class="description last"> <p>Name of the server publication.</p></td> </tr> <tr> <td class="name"><code>arguments</code></td> <td class="type"> <span class="param-type">Array</span> </td> <td class="default"> </td> <td class="description last"> <span class="optional">optional</span> <p>Array of parameters to pass to the remote method. Pass an empty array or don't pass anything if you do not wish to pass any parameters.</p></td> </tr> <tr> <td class="name"><code>atBeginning</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="default"> false </td> <td class="description last"> <span class="optional">optional</span> <p>If true puts method call at the beginning of the requests queue.</p></td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Returns:</h5> <table class="params"> <thead> <tr> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="type"> Promise </td> <td class="description last"><ul> <li>Promise object, which resolves when receives a result send by server and rejects when receives an error send by server.</li> </ul></td> </tr> </tbody> </table> <h5>Example</h5> <pre class="prettyprint"><code>server.apply("method1").then(function(result) { console.log(result); //show result message in console if (result.someId) { //server sends us someId, lets call next method using this id return server.apply("method2",[result.someId]); } else { //we didn't recieve an id, lets throw an error throw "no id sent"; } }).then(function(result) { console.log(result); //show result message from second method }).catch(function(error) { console.log(result); //show error message in console });</code></pre> </dd> <dt> <div class="nameContainer"> <h4 class="name" id="call"> <a class="share-icon" href="#call"><span class="glyphicon glyphicon-link"></span></a> <span class=""> call </span> <span class="signature">(method, <span class="optional">args</span>)</span><span class="type-signature">Promise</span> </h4> </div> </dt> <dd> <div class="description"> <p>Calls a remote method with arguments passed after the first argument. Syntactic sugar for @see apply.</p> </div> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>method</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last"> <p>Name of the server publication.</p></td> </tr> <tr> <td class="name"><code>args</code></td> <td class="type"> <span class="param-type">any</span> </td> <td class="description last"> <span class="optional">optional</span> <span class="repeatable">repeatable</span> <p>List of parameters to pass to the remote method. Parameters are passed as function arguments.</p></td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Returns:</h5> <table class="params"> <thead> <tr> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="type"> Promise </td> <td class="description last"><ul> <li>Promise object, which resolves when receives a result send by server and rejects when receives an error send by server.</li> </ul></td> </tr> </tbody> </table> </dd> <dt> <div class="nameContainer"> <h4 class="name" id="clearData"> <a class="share-icon" href="#clearData"><span class="glyphicon glyphicon-link"></span></a> <span class=""> clearData </span> <span class="signature">()</span><span class="type-signature">Promise</span> </h4> </div> </dt> <dd> <div class="description"> <p>Removes all documents like if it was removed by the server publication.</p> </div> <dl class="details"> </dl> <h5>Returns:</h5> <table class="params"> <thead> <tr> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="type"> Promise </td> <td class="description last"><ul> <li>Resolves when data is successfully removed.</li> </ul></td> </tr> </tbody> </table> </dd> <dt> <div class="nameContainer"> <h4 class="name" id="collection"> <a class="share-icon" href="#collection"><span class="glyphicon glyphicon-link"></span></a> <span class=""> collection </span> <span class="signature">(name)</span><span class="type-signature"><a href="ddpCollection.html">ddpCollection</a></span> </h4> </div> </dt> <dd> <div class="description"> <p>Use this for fetching the subscribed data and for reactivity inside the collection.</p> </div> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>name</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last"> <p>Collection name.</p></td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Returns:</h5> <table class="params"> <thead> <tr> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="type"> <a href="ddpCollection.html">ddpCollection</a> </td> <td class="description last"></td> </tr> </tbody> </table> </dd> <dt> <div class="nameContainer"> <h4 class="name" id="connect"> <a class="share-icon" href="#connect"><span class="glyphicon glyphicon-link"></span></a> <span class=""> connect </span> <span class="signature">()</span><span class="type-signature">Promise</span> </h4> </div> </dt> <dd> <div class="description"> <p>Connects to the ddp server. The method is called automatically by the class constructor if the autoConnect option is set to true (default behavior).</p> </div> <dl class="details"> </dl> <h5>Returns:</h5> <table class="params"> <thead> <tr> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="type"> Promise </td> <td class="description last"><ul> <li>Promise which resolves when connection is established.</li> </ul></td> </tr> </tbody> </table> </dd> <dt> <div class="nameContainer"> <h4 class="name" id="disconnect"> <a class="share-icon" href="#disconnect"><span class="glyphicon glyphicon-link"></span></a> <span class=""> disconnect </span> <span class="signature">()</span><span class="type-signature">Promise</span> </h4> </div> </dt> <dd> <div class="description"> <p>Disconnects from the ddp server by closing the WebSocket connection. You can listen on the disconnected event to be notified of the disconnection.</p> </div> <dl class="details"> </dl> <h5>Returns:</h5> <table class="params"> <thead> <tr> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="type"> Promise </td> <td class="description last"><ul> <li>Promise which resolves when connection is closed.</li> </ul></td> </tr> </tbody> </table> </dd> <dt> <div class="nameContainer"> <h4 class="name" id="exportData"> <a class="share-icon" href="#exportData"><span class="glyphicon glyphicon-link"></span></a> <span class=""> exportData </span> <span class="signature">(<span class="optional">format</span>)</span><span class="type-signature">Object | string</span> </h4> </div> </dt> <dd> <div class="description"> <p>Exports the data</p> </div> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>format</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="default"> 'string' </td> <td class="description last"> <span class="optional">optional</span> <p>Possible values are 'string' (EJSON string) and 'raw' (EJSON).</p></td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Returns:</h5> <table class="params"> <thead> <tr> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="type"> Object | string </td> <td class="description last"><ul> <li>EJSON string or EJSON.</li> </ul></td> </tr> </tbody> </table> </dd> <dt> <div class="nameContainer"> <h4 class="name" id="importData"> <a class="share-icon" href="#importData"><span class="glyphicon glyphicon-link"></span></a> <span class=""> importData </span> <span class="signature">(data)</span><span class="type-signature">Promise</span> </h4> </div> </dt> <dd> <div class="description"> <p>Imports the data like if it was published by the server.</p> </div> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>data</code></td> <td class="type"> <span class="param-type">Object</span> | <span class="param-type">string</span> </td> <td class="description last"> <p>ESJON string or EJSON.</p></td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Returns:</h5> <table class="params"> <thead> <tr> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="type"> Promise </td> <td class="description last"><ul> <li>Resolves when data is successfully imported.</li> </ul></td> </tr> </tbody> </table> </dd> <dt> <div class="nameContainer"> <h4 class="name" id="markAsReady"> <a class="share-icon" href="#markAsReady"><span class="glyphicon glyphicon-link"></span></a> <span class=""> markAsReady </span> <span class="signature">(subs)</span><span class="type-signature">Promise</span> </h4> </div> </dt> <dd> <div class="description"> <p>Marks every passed @see ddpSubscription object as ready like if it was done by the server publication.</p> </div> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>subs</code></td> <td class="type"> <span class="param-type">Array</span> </td> <td class="description last"> <p>Array of @see ddpSubscription objects.</p></td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Returns:</h5> <table class="params"> <thead> <tr> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="type"> Promise </td> <td class="description last"><ul> <li>Resolves when all passed subscriptions are marked as ready.</li> </ul></td> </tr> </tbody> </table> </dd> <dt> <div class="nameContainer"> <h4 class="name" id="on"> <a class="share-icon" href="#on"><span class="glyphicon glyphicon-link"></span></a> <span class=""> on </span> <span class="signature">(event, f)</span><span class="type-signature"><a href="ddpEventListener.html">ddpEventListener</a></span> </h4> </div> </dt> <dd> <div class="description"> <p>Starts listening server for basic DDP event running f each time the message arrives.</p> </div> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>event</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last"> <p>Any event name from DDP specification. Default suppoted events: <code>connected</code>, <code>disconnected</code>, <code>added</code>, <code>changed</code>, <code>removed</code>, <code>ready</code>, <code>nosub</code>, <code>error</code>, <code>ping</code>, <code>pong</code>.</p></td> </tr> <tr> <td class="name"><code>f</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last"> <p>Function which receives a message from a DDP server as a first argument each time server is invoking event.</p></td> </tr> </tbody> </table> <dl class="details"> </dl> <h5>Returns:</h5> <table class="params"> <thead> <tr> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="type"> <a href="ddpEventListener.html">ddpEventListener</a> </td> <td class="description last"></td> </tr> </tbody> </table> <h5>Example</h5> <pre class="prettyprint"><code>server.on('connected', () => { // you can show a success message here }); server.on('disconnected', () => { // you can show a reconnection message here });</code></pre> </dd> <dt> <div class="nameContainer"> <h4 class="name" id="stopChangeListeners"> <a class="share-icon" href="#stopChangeListeners"><span class="glyphicon glyphicon-link"></span></a> <span class=""> stopChangeListeners </span> <span class="signature">()</span> </h4> </div> </dt> <dd> <div class="description"> <p>Stops all reactivity.</p> </div> <dl class="details"> </dl> </dd> <dt> <div class="nameContainer"> <h4 class="name" id="sub"> <a class="share-icon" href="#sub"><span class="glyphicon glyphicon-link"></span></a> <span class=""> sub </span> <span class="signature">(pubname, <span class="optional">arguments</span>)</span><span class="type-signature"><a href="ddpSubscription.html">ddpSubscription</a></span> </h4> </div> </dt> <dd> <div class="description"> <p>Tries to subscribe to a specific publication on server.</p> </div> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>pubname</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last"> <