ghost-portal/packages/react-hooks/src/track/util.ts
Jaco Greeff e0acd15b43
useAccounts hook (#1898)
* useAccounts hook

* Drop some withRouter

* Add setImmediate to trackStream

* Combine unsubscribe into subscribe

* Use before define

* Ass trackPromise

* Cleanup mapping for params

* Addressbook display
2019-11-16 10:13:07 +01:00

26 lines
828 B
TypeScript

// Copyright 2017-2019 @polkadot/react-hooks authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Params } from './types';
import { isNull, isUndefined } from '@polkadot/util';
export const dummyPromise = Promise.resolve((): void => {
// we do nothing, this is a noop
});
export function transformIdentity (value: any): any {
return value;
}
// extract the serialized and mapped params, all ready for use in our call
export function extractParams (params: any[], paramMap: (params: any[]) => any): [string, Params | null] {
return [
JSON.stringify({ a: params }),
params.length === 0 || !params.some((param): boolean => isNull(param) || isUndefined(null))
? paramMap(params)
: null
];
}