docs(nx): adds docs for readAll and readFirst
This commit is contained in:
parent
47ab8a5d72
commit
73c8c6c7fd
@ -2,7 +2,9 @@ import {ModuleWithProviders, NgModule} from '@angular/core';
|
|||||||
import {DataPersistence} from './data-persistence';
|
import {DataPersistence} from './data-persistence';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @whatItDoes Provides services simplifying enterprise Angular development.
|
* @whatItDoes Provides services for enterprise Angular applications.
|
||||||
|
*
|
||||||
|
* See {@link DataPersistence} for more information.
|
||||||
*/
|
*/
|
||||||
@NgModule({})
|
@NgModule({})
|
||||||
export class NxModule {
|
export class NxModule {
|
||||||
|
|||||||
@ -3,10 +3,34 @@ import {first} from 'rxjs/operator/first';
|
|||||||
import {toArray} from 'rxjs/operator/toArray';
|
import {toArray} from 'rxjs/operator/toArray';
|
||||||
import {toPromise} from 'rxjs/operator/toPromise';
|
import {toPromise} from 'rxjs/operator/toPromise';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @whatItDoes reads all the values from an observable and returns a promise
|
||||||
|
* with an array of all values. This should be used in combination with async/await.
|
||||||
|
*
|
||||||
|
* ## Example
|
||||||
|
*
|
||||||
|
* ```typescript
|
||||||
|
* const obs = of(1, 2, 3, 4);
|
||||||
|
* const res = await readAll(obs)
|
||||||
|
* expect(res).toEqual([1, 2, 3, 4]);
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
export function readAll<T>(o: Observable<T>): Promise<T[]> {
|
export function readAll<T>(o: Observable<T>): Promise<T[]> {
|
||||||
return toPromise.call(toArray.call(o));
|
return toPromise.call(toArray.call(o));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @whatItDoes reads the first value from an observable and returns a promise
|
||||||
|
* with it. This should be used in combination with async/await.
|
||||||
|
*
|
||||||
|
* ## Example
|
||||||
|
*
|
||||||
|
* ```typescript
|
||||||
|
* const obs = of(1, 2, 3, 4);
|
||||||
|
* const res = await readFirst(obs)
|
||||||
|
* expect(res).toEqual(1);
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
export function readFirst<T>(o: Observable<T>): Promise<T> {
|
export function readFirst<T>(o: Observable<T>): Promise<T> {
|
||||||
return toPromise.call(first.call(o));
|
return toPromise.call(first.call(o));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user