UNPKG

@rx-angular/cdk

Version:

@rx-angular/cdk is a Component Development Kit for ergonomic and highly performant angular applications. It helps to to build Large scale applications, UI libs, state management, rendering systems and much more. Furthermore the unique way of mixing reacti

56 lines (55 loc) 1.34 kB
/** * @description * Converts a dictionary of type {[key: string]: T} to array T[]. * * @example * * const creaturesDictionary = { * '1': {id: 1, type: 'cat'}, * '2': {id: 2, type: 'dog'}, * '3': {id: 3, type: 'parrot'} * }; * * const creaturesArray = dictionaryToArray(creaturesDictionary); * * // creaturesArray will be: * // [{id: 1, type: 'cat'}, {id: 2, type: 'dog'}, {id: 3, type: 'parrot'}]; * * @example * // Usage with RxState * * export class ListComponent { * readonly removeName$ = new Subject(); * * constructor( * private state: RxState<ComponentState>, * private api: ApiService * ) { * // Reactive implementation * state.connect( * 'creatures', * this.api.creaturesDictionary$, * (_, creatures) => { * return dictionaryToArray(creatures); * } * ); * } * * // Imperative implementation * removeName(): void { * this.api.creaturesDictionary$.pipe( * // subscription handling logic * ).subscribe( * dictionary => this.set({creatures: dictionaryToArray(dictionary)}) * ); * } * } * * @returns T[]; * * @docsPage dictionaryToArray * @docsCategory transformation-helpers */ export declare function dictionaryToArray<T>(dictionary: { [key: string]: T; }): T[];