UNPKG

@flopflip/react-redux

Version:

A feature toggle wrapper to use LaunchDarkly with React Redux

100 lines (81 loc) 4.72 kB
import * as _flopflip_types from '@flopflip/types'; import { TFlagName, TFlagVariation, TAdapter, TConfigureAdapterChildren, TFlags, TConfigureAdapterProps, TFlagsContext, TAdaptersStatus, TAdapterIdentifiers, TAdapterArgs } from '@flopflip/types'; import React from 'react'; import * as redux from 'redux'; import { StoreEnhancerStoreCreator, Reducer, Store } from 'redux'; import { TToggleFeatureProps } from '@flopflip/react'; export { ReconfigureAdapter as ReconfigureFlopFlip, useAdapterReconfiguration } from '@flopflip/react'; type TBranchOnFeatureToggleOptions = { flag: TFlagName; variation?: TFlagVariation; }; declare function branchOnFeatureToggle<OwnProps extends Record<string, unknown>>({ flag: flagName, variation: flagVariation }: TBranchOnFeatureToggleOptions, UntoggledComponent?: React.ComponentType): (ToggledComponent: React.ComponentType<OwnProps>) => (ownProps: OwnProps) => React.JSX.Element | null; type TBaseProps = { readonly children?: TConfigureAdapterChildren; readonly shouldDeferAdapterConfiguration?: boolean; readonly defaultFlags?: TFlags; }; type TProps$1<AdapterInstance extends TAdapter> = TBaseProps & TConfigureAdapterProps<AdapterInstance>; declare function Configure<AdapterInstance extends TAdapter>({ adapter, adapterArgs, children, defaultFlags, shouldDeferAdapterConfiguration, }: TProps$1<AdapterInstance>): React.JSX.Element; declare namespace Configure { var displayName: string; } declare const STATE_SLICE = "@flopflip"; type TState = { [STATE_SLICE]: { flags?: TFlagsContext; status?: TAdaptersStatus; }; }; declare const selectFlags: () => (state: TState) => TFlagsContext; declare const selectFlag: (flagName: TFlagName, adapterIdentifiers: TAdapterIdentifiers[]) => (state: TState) => TFlagVariation; declare const flopflipReducer: redux.Reducer<{ flags: TFlagsContext; status: _flopflip_types.TAdaptersStatus; }, redux.UnknownAction, Partial<{ flags: TFlagsContext | undefined; status: _flopflip_types.TAdaptersStatus | undefined; }>>; declare const createFlopflipReducer: (preloadedState?: TFlagsContext) => redux.Reducer<{ flags: TFlagsContext; status: _flopflip_types.TAdaptersStatus; }, redux.UnknownAction | { payload: { adapterIdentifiers: string[]; id?: _flopflip_types.TAdapterIdentifiers; flags: _flopflip_types.TFlags; }; type: "flags/updateFlags"; }, Partial<{ flags: never; status: _flopflip_types.TAdaptersStatus | undefined; }>>; declare function createFlopFlipEnhancer(adapter: TAdapter, adapterArgs: TAdapterArgs): <StoreState extends TState>(next: StoreEnhancerStoreCreator<StoreState>) => (reducer: Reducer<StoreState>, preloadedState?: StoreState) => Store; type InjectedProps$1 = Record<string, TFlagVariation>; declare const injectFeatureToggle: <OwnProps extends Record<string, unknown>>(flagName: TFlagName, propKey?: string) => (Component: React.ComponentType<any>) => React.ComponentType<OwnProps & InjectedProps$1>; type InjectedProps = Record<string, TFlags>; declare const injectFeatureToggles: <OwnProps extends Record<string, unknown>>(flagNames: TFlagName[], propKey?: string) => (Component: React.ComponentType) => React.ComponentType<OwnProps & InjectedProps>; type TProps = { flag: TFlagName; variation?: TFlagVariation; } & Omit<TToggleFeatureProps, 'isFeatureEnabled'>; declare function ToggleFeature<OwnProps extends TProps>({ flag, variation, ...remainingProps }: OwnProps): React.JSX.Element; declare namespace ToggleFeature { var displayName: string; } type TUseAdapterStatusArgs = { adapterIdentifiers?: TAdapterIdentifiers[]; }; declare function useAdapterStatus({ adapterIdentifiers }?: TUseAdapterStatusArgs): { isReady: boolean; isUnconfigured: boolean; isConfiguring: boolean; isConfigured: boolean; }; declare function useAllFeatureToggles(): TFlags; declare function useFeatureToggle(flagName: TFlagName, flagVariation?: TFlagVariation): boolean; declare function useFeatureToggles(flags: TFlags): boolean[]; declare function useFlagVariation(flagName?: TFlagName): TFlagVariation; declare function useFlagVariations(flagNames: Array<TFlagName | undefined>): TFlagVariation[]; declare const version = "__@FLOPFLIP/VERSION_OF_RELEASE__"; export { Configure as ConfigureFlopFlip, STATE_SLICE as FLOPFLIP_STATE_SLICE, ToggleFeature, branchOnFeatureToggle, createFlopFlipEnhancer, createFlopflipReducer, flopflipReducer, injectFeatureToggle, injectFeatureToggles, selectFlag as selectFeatureFlag, selectFlags as selectFeatureFlags, useAdapterStatus, useAllFeatureToggles, useFeatureToggle, useFeatureToggles, useFlagVariation, useFlagVariations, version };