Move api-derive to correct location (#4343)
* Move api-derive to correct location * Adjust (linting ok) * No composite * ApiDerive split * Adjust * Still WIP, getting closer * It lints * derive build issues sorted * It builds :) * Add system_health to mock * api-augment usage * Cleanups * Adjust paths * linting * Some <'s * Revert <>'s * linting * ordering * Augmentation tweaks * yarn.lock * export
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { DeriveApi } from '../types';
|
||||
|
||||
import { map } from 'rxjs';
|
||||
|
||||
import { memo } from '@polkadot/rpc-core';
|
||||
|
||||
export function firstObservable <T> (obs: Observable<T[]>): Observable<T> {
|
||||
return obs.pipe(map(([a]) => a));
|
||||
}
|
||||
|
||||
export function firstMemo <T, A extends any[]> (fn: (api: DeriveApi, ...args: A) => Observable<T[]>): (instanceId: string, api: DeriveApi) => (...args: A) => Observable<T> {
|
||||
return (instanceId: string, api: DeriveApi) =>
|
||||
memo(instanceId, (...args: A) =>
|
||||
firstObservable<T>(fn(api, ...args))
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user