docs/index.html
<!doctype html>
<html class="default no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>seng-disposable</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="assets/css/main.css">
</head>
<body>
<header>
<div class="tsd-page-toolbar">
<div class="container">
<div class="table-wrap">
<div class="table-cell" id="tsd-search" data-index="assets/js/search.js" data-base=".">
<div class="field">
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
<input id="tsd-search-field" type="text" />
</div>
<ul class="results">
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li>
</ul>
<a href="index.html" class="title">seng-disposable</a>
</div>
<div class="table-cell" id="tsd-widgets">
<div id="tsd-filter">
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
<div class="tsd-filter-group">
<div class="tsd-select" id="tsd-filter-visibility">
<span class="tsd-select-label">All</span>
<ul class="tsd-select-list">
<li data-value="public">Public</li>
<li data-value="protected">Public/Protected</li>
<li data-value="private" class="selected">All</li>
</ul>
</div>
<input type="checkbox" id="tsd-filter-inherited" checked />
<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
<input type="checkbox" id="tsd-filter-externals" checked />
<label class="tsd-widget" for="tsd-filter-externals">Externals</label>
<input type="checkbox" id="tsd-filter-only-exported" />
<label class="tsd-widget" for="tsd-filter-only-exported">Only exported</label>
</div>
</div>
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
</div>
</div>
</div>
</div>
<div class="tsd-page-title">
<div class="container">
<ul class="tsd-breadcrumb">
<li>
<a href="globals.html">Globals</a>
</li>
</ul>
<h1> seng-disposable</h1>
</div>
</div>
</header>
<div class="container container-main">
<div class="row">
<div class="col-8 col-content">
<div class="tsd-panel tsd-typography">
<p><a href="https://travis-ci.org/mediamonks/seng-disposable"><img src="https://img.shields.io/travis/mediamonks/seng-disposable.svg?maxAge=2592000" alt="Travis"></a>
<a href="https://codeclimate.com/github/mediamonks/seng-disposable"><img src="https://img.shields.io/codeclimate/github/mediamonks/seng-disposable.svg?maxAge=2592000" alt="Code Climate"></a>
<a href="https://coveralls.io/github/mediamonks/seng-disposable?branch=master"><img src="https://img.shields.io/coveralls/mediamonks/seng-disposable.svg?maxAge=2592000" alt="Coveralls"></a>
<a href="https://www.npmjs.com/package/seng-disposable"><img src="https://img.shields.io/npm/v/seng-disposable.svg?maxAge=2592000" alt="npm"></a>
<a href="https://www.npmjs.com/package/seng-disposable"><img src="https://img.shields.io/npm/dm/seng-disposable.svg?maxAge=2592000" alt="npm"></a></p>
<h1 id="seng-disposable">seng-disposable</h1>
<p>seng-disposable provides a basic framework for disposable classes and objects. Disposable is used as a basis for
many Seng libraries because it provides a common interface which can be passed around to be disposed at a later time.</p>
<h2 id="installation">Installation</h2>
<h3 id="yarn-npm">yarn / npm</h3>
<pre><code class="lang-sh">yarn add seng-disposable
</code></pre>
<pre><code class="lang-sh">npm i -S seng-disposable
</code></pre>
<h3 id="other">other</h3>
<p>We also have browser, amd, commonjs, umd, systemjs and es6 versions of
this module available attached to the <a href="https://github.com/mediamonks/seng-disposable/releases">Github Releases</a>.</p>
<!---
Note: The below cannot be used yet, as there is no way to link to a
specific version yet without updating this readme manually after each
new version.
### browser
```html
<script src="http://mediamonks-development.s3.amazonaws.com/seng/libs/seng-disposable/1.2.0/seng-disposable.min.js"></script>
```
```js
console.log(window.SengDisposable)
```
### other
Besides the browser version, there are other versions available for
download as well:
- [browser](http://mediamonks-development.s3.amazonaws.com/seng/libs/seng-disposable/1.2.0/seng-disposable.js) (and [minified](http://mediamonks-development.s3.amazonaws.com/seng/libs/seng-disposable/1.2.0/seng-disposable.min.js))
- [umd](http://mediamonks-development.s3.amazonaws.com/seng/libs/seng-disposable/1.2.0/seng-disposable.js) (and [minified](http://mediamonks-development.s3.amazonaws.com/seng/libs/seng-disposable/1.2.0/seng-disposable-umd.min.js))
- [amd](http://mediamonks-development.s3.amazonaws.com/seng/libs/seng-disposable/1.2.0/seng-disposable-amd.js)
- [commonjs](http://mediamonks-development.s3.amazonaws.com/seng/libs/seng-disposable/1.2.0/seng-disposable-commonjs.js)
- [systemjs](http://mediamonks-development.s3.amazonaws.com/seng/libs/seng-disposable/1.2.0/seng-disposable-system.js)
- [es6](http://mediamonks-development.s3.amazonaws.com/seng/libs/seng-disposable/1.2.0/seng-disposable-es6.zip)
-->
<h3 id="manual">manual</h3>
<p>Check the <strong>build</strong> section below to see your you can build for all the
targets yourself.</p>
<h2 id="usage">Usage</h2>
<pre><code class="lang-ts"><span class="hljs-keyword">import</span> Disposable <span class="hljs-keyword">from</span> <span class="hljs-string">'seng-disposable'</span>;
<span class="hljs-keyword">class</span> AsyncThinger <span class="hljs-keyword">extends</span> Disposable {
interval:<span class="hljs-built_in">number</span>;
start() {
<span class="hljs-keyword">this</span>.interval = setInterval(<span class="hljs-function"><span class="hljs-params">()</span> =></span> <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'hello world!'</span>));
}
dispose() {
<span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.interval !== <span class="hljs-built_in">void</span> <span class="hljs-number">0</span>) {
clearInterval(<span class="hljs-keyword">this</span>.interval);
<span class="hljs-keyword">this</span>.interval = <span class="hljs-built_in">void</span> <span class="hljs-number">0</span>;
}
<span class="hljs-keyword">super</span>.dispose();
}
}
<span class="hljs-comment">// since all objects implementing IDisposable provide the same way to dispose it, we can simply create an array</span>
<span class="hljs-comment">// that contains IDisposable objects, without having to care about what they actually are.</span>
<span class="hljs-keyword">let</span> disposables:<span class="hljs-built_in">Array</span><IDisposable> = [];
disposables.push(<span class="hljs-keyword">new</span> AsyncThinger());
disposables.push(<span class="hljs-keyword">new</span> AsyncThinger());
disposables.push(<span class="hljs-keyword">new</span> AsyncThinger());
disposables.push(<span class="hljs-keyword">new</span> AsyncThinger());
disposables.forEach(<span class="hljs-function"><span class="hljs-params">disposable</span> =></span> disposable.dispose());
</code></pre>
<h2 id="documentation">Documentation</h2>
<p>View the <a href="http://mediamonks.github.io/seng-disposable/">generated documentation</a>.</p>
<h2 id="building">Building</h2>
<p>In order to build seng-disposable, ensure that you have <a href="http://git-scm.com/downloads">Git</a>
and <a href="http://nodejs.org/">Node.js</a> installed.</p>
<p>Clone a copy of the repo:</p>
<pre><code class="lang-sh">git <span class="hljs-built_in">clone</span> https://github.com/mediamonks/seng-disposable.git
</code></pre>
<p>Change to the seng-disposable directory:</p>
<pre><code class="lang-sh"><span class="hljs-built_in">cd</span> seng-disposable
</code></pre>
<p>Install dev dependencies:</p>
<pre><code class="lang-sh">yarn
</code></pre>
<p>Use one of the following main scripts:</p>
<pre><code class="lang-sh">yarn build <span class="hljs-comment"># build this project</span>
yarn dev <span class="hljs-comment"># run dev-watch mode, serving example/index.html in the browser</span>
yarn generate <span class="hljs-comment"># generate all artifacts (compiles ts, webpack, docs and coverage)</span>
yarn typings <span class="hljs-comment"># install .d.ts dependencies (done on install)</span>
yarn <span class="hljs-built_in">test</span>:unit <span class="hljs-comment"># run the unit tests</span>
yarn validate <span class="hljs-comment"># runs validation scripts, including test, lint and coverage check</span>
yarn lint <span class="hljs-comment"># run tslint on this project</span>
yarn doc <span class="hljs-comment"># generate typedoc documentation</span>
</code></pre>
<p>When installing this module, it adds a pre-push hook, that runs the <code>validate</code>
script before committing, so you can be sure that everything checks out.</p>
<p>If you want to create the distribution files yourself, you can run the
<code>build-dist</code> script, and the following files will get generated in the
<code>dist</code> folder:</p>
<ul>
<li><strong>/dist/seng-disposable.js</strong>: bundled with webpack, can be loaded from
a script tag, available as <code>window.SengDisposable</code></li>
<li><strong>/dist/seng-disposable.min.js</strong>: same as above, but minified</li>
<li><strong>/dist/seng-disposable-amd.js</strong>: bundled with webpack, can be used
with e.g. requirejs</li>
<li><strong>/dist/seng-disposable-commonjs.js</strong>: bundled with webpack, can be
used in systems that support commonjs, but you should just use npm</li>
<li><strong>/dist/seng-disposable-umd.js</strong>: bundled with webpack, works in the
browser, with requirejs, and in a commonjs system</li>
<li><strong>/dist/seng-disposable-umd.min.js</strong>: same as above, but minified</li>
<li><strong>/dist/seng-disposable-system.js</strong>: bundled with typescript, can be
used in systems that support systemjs</li>
<li><strong>/dist/seng-disposable-es6.zip</strong>: transpiled with typescript, only
types are removed from the source files</li>
</ul>
<h2 id="contribute">Contribute</h2>
<p>View <a href="./CONTRIBUTING.md">CONTRIBUTING.md</a></p>
<h2 id="changelog">Changelog</h2>
<p>View <a href="./CHANGELOG.md">CHANGELOG.md</a></p>
<h2 id="authors">Authors</h2>
<p>View <a href="./AUTHORS.md">AUTHORS.md</a></p>
<h2 id="license">LICENSE</h2>
<p><a href="./LICENSE">MIT</a> © MediaMonks</p>
</div>
</div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav class="tsd-navigation primary">
<ul>
<li class="globals ">
<a href="globals.html"><em>Globals</em></a>
</li>
</ul>
</nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
<li class=" tsd-kind-class">
<a href="classes/disposable.html" class="tsd-kind-icon">Disposable</a>
</li>
<li class=" tsd-kind-interface">
<a href="interfaces/idisposable.html" class="tsd-kind-icon">IDisposable</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<footer class="with-border-bottom">
<div class="container">
<h2>Legend</h2>
<div class="tsd-legend-group">
<ul class="tsd-legend">
<li class="tsd-kind-module"><span class="tsd-kind-icon">Module</span></li>
<li class="tsd-kind-object-literal"><span class="tsd-kind-icon">Object literal</span></li>
<li class="tsd-kind-variable"><span class="tsd-kind-icon">Variable</span></li>
<li class="tsd-kind-function"><span class="tsd-kind-icon">Function</span></li>
<li class="tsd-kind-function tsd-has-type-parameter"><span class="tsd-kind-icon">Function with type parameter</span></li>
<li class="tsd-kind-index-signature"><span class="tsd-kind-icon">Index signature</span></li>
<li class="tsd-kind-type-alias"><span class="tsd-kind-icon">Type alias</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-enum"><span class="tsd-kind-icon">Enumeration</span></li>
<li class="tsd-kind-enum-member"><span class="tsd-kind-icon">Enumeration member</span></li>
<li class="tsd-kind-property tsd-parent-kind-enum"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-enum"><span class="tsd-kind-icon">Method</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-interface"><span class="tsd-kind-icon">Interface</span></li>
<li class="tsd-kind-interface tsd-has-type-parameter"><span class="tsd-kind-icon">Interface with type parameter</span></li>
<li class="tsd-kind-constructor tsd-parent-kind-interface"><span class="tsd-kind-icon">Constructor</span></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li>
<li class="tsd-kind-index-signature tsd-parent-kind-interface"><span class="tsd-kind-icon">Index signature</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-class"><span class="tsd-kind-icon">Class</span></li>
<li class="tsd-kind-class tsd-has-type-parameter"><span class="tsd-kind-icon">Class with type parameter</span></li>
<li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li>
<li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class"><span class="tsd-kind-icon">Accessor</span></li>
<li class="tsd-kind-index-signature tsd-parent-kind-class"><span class="tsd-kind-icon">Index signature</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited constructor</span></li>
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited accessor</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected accessor</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private accessor</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static property</span></li>
<li class="tsd-kind-call-signature tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static method</span></li>
</ul>
</div>
</div>
</footer>
<div class="container tsd-generator">
<p>Generated using <a href="http://typedoc.org/" target="_blank">TypeDoc</a></p>
</div>
<div class="overlay"></div>
<script src="assets/js/main.js"></script>
<script>if (location.protocol == 'file:') document.write('<script src="assets/js/search.js"><' + '/script>');</script>
</body>
</html>