Move Rx API wrapper into api (#87)

* Move Rx API wrapper into api

* Bump
This commit is contained in:
Jaco Greeff
2018-05-07 12:01:09 +02:00
committed by GitHub
parent 2c6a853f73
commit 92c7c2cc1f
25 changed files with 545 additions and 12 deletions
+23
View File
@@ -0,0 +1,23 @@
// Copyright 2017-2018 Jaco Greeff
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
// @flow
import type { ApiInterface, ApiInterface$Section } from '@polkadot/api/types';
import type { InterfaceTypes } from '@polkadot/api-jsonrpc/types';
import type { RxApiInterface$Section } from './types';
const observable = require('./observable');
module.exports = function createInterface (api: ApiInterface, sectionName: InterfaceTypes): RxApiInterface$Section {
const section: ApiInterface$Section = api[sectionName];
return Object
.keys(section)
.filter((name) => !['subscribe', 'unsubscribe'].includes(name))
.reduce((observables, name) => {
observables[name] = observable(`${sectionName}_${name}`, name, section);
return observables;
}, ({}: $Shape<RxApiInterface$Section>));
};