Skip to content

Commit

Permalink
[database] Add types for useListKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbianca committed Nov 9, 2018
1 parent e983fe5 commit a6d8b1b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions database/index.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type ListHook = {
loading: boolean;
value: DataSnapshot[];
};
export type ListKeysHook<T> = {
export type ListKeysHook = {
error?: Object;
loading: boolean;
value: string[];
Expand All @@ -28,7 +28,7 @@ export type ObjectValHook<T> = {
};

declare export function useList(query: Query): ListHook;
declare export function useListKeys<T>(query: Query): ListKeysHook<T>;
declare export function useListKeys(query: Query): ListKeysHook;
declare export function useListVals<T>(query: Query, keyField?: string): ListValsHook<T>;
declare export function useObject(query: Query): ObjectHook;
declare export function useObjectVal<T>(query: Query): ObjectValHook<T>;
1 change: 1 addition & 0 deletions database/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { default as useList, ListHook } from './useList';
export { default as useListKeys, ListKeysHook } from './useListKeys';
export { default as useListVals, ListValsHook } from './useListVals';
export { default as useObject, ObjectHook } from './useObject';
export { default as useObjectVal, ObjectValHook } from './useObjectVal';
5 changes: 3 additions & 2 deletions database/useListKeys.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { database } from 'firebase';
import useList from './useList';

export type ListKeysHook<T> = {
export type ListKeysHook = {
error?: Object;
loading: boolean;
value: string[];
};

export default <T>(query: database.Query): ListKeysHook<T> => {
export default (query: database.Query): ListKeysHook => {
const { error, loading, value } = useList(query);
// @ts-ignore
return {
error,
loading,
Expand Down

0 comments on commit a6d8b1b

Please sign in to comment.