Convert all to named imports (#414)

This commit is contained in:
Jaco Greeff
2020-12-09 01:41:44 +01:00
committed by GitHub
parent a5434d4428
commit 7e494673e0
69 changed files with 175 additions and 193 deletions
@@ -2,6 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
import { accountKey } from '../defaults';
import genericSubject from './genericSubject';
import { genericSubject } from './genericSubject';
export default genericSubject(accountKey, true);
export const accounts = genericSubject(accountKey, true);
@@ -2,6 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
import { addressKey } from '../defaults';
import genericSubject from './genericSubject';
import { genericSubject } from './genericSubject';
export default genericSubject(addressKey);
export const addresses = genericSubject(addressKey);
@@ -2,6 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
import { contractKey } from '../defaults';
import genericSubject from './genericSubject';
import { genericSubject } from './genericSubject';
export default genericSubject(contractKey);
export const contracts = genericSubject(contractKey);
@@ -5,7 +5,7 @@ import { BehaviorSubject } from 'rxjs';
const subject = new BehaviorSubject(false);
export default {
export const env = {
isDevelopment: (): boolean =>
subject.getValue(),
set: (isDevelopment: boolean): void => {
@@ -7,11 +7,11 @@ import type { AddressSubject, SingleAddress, SubjectInfo } from './types';
import { BehaviorSubject } from 'rxjs';
import createOptionItem from '../options/item';
import development from './development';
import { createOptionItem } from '../options/item';
import { env } from './env';
function callNext (current: SubjectInfo, subject: BehaviorSubject<SubjectInfo>, withTest: boolean): void {
const isDevMode = development.isDevelopment();
const isDevMode = env.isDevelopment();
const filtered: SubjectInfo = {};
Object.keys(current).forEach((key): void => {
@@ -25,12 +25,12 @@ function callNext (current: SubjectInfo, subject: BehaviorSubject<SubjectInfo>,
subject.next(filtered);
}
export default function genericSubject (keyCreator: (address: string) => string, withTest = false): AddressSubject {
export function genericSubject (keyCreator: (address: string) => string, withTest = false): AddressSubject {
let current: SubjectInfo = {};
const subject = new BehaviorSubject({});
const next = (): void => callNext(current, subject, withTest);
development.subject.subscribe(next);
env.subject.subscribe(next);
return {
add: (store: KeyringStore, address: string, json: KeyringJson, type?: KeypairType): SingleAddress => {
@@ -43,7 +43,7 @@ export default function genericSubject (keyCreator: (address: string) => string,
};
// we do not store dev accounts, injected or hardware (the latter two are external/transient)
if (!json.meta.isInjected && !json.meta.isHardware && (!json.meta.isTesting || development.isDevelopment())) {
if (!json.meta.isInjected && !json.meta.isHardware && (!json.meta.isTesting || env.isDevelopment())) {
store.set(keyCreator(address), json);
}
+4 -4
View File
@@ -6,9 +6,9 @@ import type { SubjectInfo } from './types';
import { combineLatest } from 'rxjs';
import { map } from 'rxjs/operators';
import accounts from './accounts';
import addresses from './addresses';
import contracts from './contracts';
import { accounts } from './accounts';
import { addresses } from './addresses';
import { contracts } from './contracts';
interface Result {
accounts: SubjectInfo;
@@ -16,7 +16,7 @@ interface Result {
contracts: SubjectInfo;
}
export default combineLatest(
export const obervableAll = combineLatest(
accounts.subject,
addresses.subject,
contracts.subject