@@ -12,7 +12,9 @@ import usePrevious from './usePrevious';
1212import decorateWithMetrics from './metrics' ;
1313import * as Logger from './Logger' ;
1414
15- type BaseUseOnyxOptions = {
15+ type UseOnyxSelector < TKey extends OnyxKey , TReturnValue = OnyxValue < TKey > > = ( data : OnyxValue < TKey > | undefined ) => TReturnValue ;
16+
17+ type UseOnyxOptions < TKey extends OnyxKey , TReturnValue > = {
1618 /**
1719 * Determines if this key in this subscription is safe to be evicted.
1820 */
@@ -46,11 +48,7 @@ type BaseUseOnyxOptions = {
4648 * is not there, it will log an alert, as it means we are using data that no one loaded and that's most probably a bug.
4749 */
4850 canBeMissing ?: boolean ;
49- } ;
50-
51- type UseOnyxSelector < TKey extends OnyxKey , TReturnValue = OnyxValue < TKey > > = ( data : OnyxValue < TKey > | undefined ) => TReturnValue ;
5251
53- type UseOnyxSelectorOption < TKey extends OnyxKey , TReturnValue > = {
5452 /**
5553 * This will be used to subscribe to a subset of an Onyx key's data.
5654 * Using this setting on `useOnyx` can have very positive performance benefits because the component will only re-render
@@ -61,8 +59,6 @@ type UseOnyxSelectorOption<TKey extends OnyxKey, TReturnValue> = {
6159 selector ?: UseOnyxSelector < TKey , TReturnValue > ;
6260} ;
6361
64- type UseOnyxOptions < TKey extends OnyxKey , TReturnValue > = BaseUseOnyxOptions & UseOnyxSelectorOption < TKey , TReturnValue > ;
65-
6662type FetchStatus = 'loading' | 'loaded' ;
6763
6864type ResultMetadata < TValue > = {
@@ -72,12 +68,6 @@ type ResultMetadata<TValue> = {
7268
7369type UseOnyxResult < TValue > = [ NonNullable < TValue > | undefined , ResultMetadata < TValue > ] ;
7470
75- function useOnyx < TKey extends OnyxKey , TReturnValue = OnyxValue < TKey > > (
76- key : TKey ,
77- options ?: BaseUseOnyxOptions & Required < UseOnyxSelectorOption < TKey , TReturnValue > > ,
78- dependencies ?: DependencyList ,
79- ) : UseOnyxResult < TReturnValue > ;
80- function useOnyx < TKey extends OnyxKey , TReturnValue = OnyxValue < TKey > > ( key : TKey , options ?: BaseUseOnyxOptions , dependencies ?: DependencyList ) : UseOnyxResult < TReturnValue > ;
8171function useOnyx < TKey extends OnyxKey , TReturnValue = OnyxValue < TKey > > (
8272 key : TKey ,
8373 options ?: UseOnyxOptions < TKey , TReturnValue > ,
0 commit comments