Skip to content

Commit eba9e4f

Browse files
rename new hooks
1 parent 88442bb commit eba9e4f

7 files changed

Lines changed: 22 additions & 22 deletions

src/useClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useClientAndContext } from './useClientAndContext';
1+
import { useSplitClient } from './useSplitClient';
22

33
/**
44
* 'useClient' is a hook that returns a client from the Split context.
@@ -9,7 +9,7 @@ import { useClientAndContext } from './useClientAndContext';
99
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#advanced-instantiate-multiple-sdk-clients}
1010
*/
1111
const useClient = (key?: SplitIO.SplitKey, trafficType?: string, attributes?: SplitIO.Attributes): SplitIO.IBrowserClient | null => {
12-
return useClientAndContext(key, trafficType, attributes).client;
12+
return useSplitClient(key, trafficType, attributes).client;
1313
};
1414

1515
export default useClient;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import { ERROR_UC_NO_USECONTEXT } from './constants';
44
import { getSplitSharedClient, checkHooks, initAttributes, IClientWithContext } from './utils';
55

66
/**
7-
* 'useClientAndContext' is a hook that returns an Split Context object with the client and its status corresponding to the provided key and trafficType.
7+
* 'useSplitClient' is a hook that returns an Split Context object with the client and its status corresponding to the provided key and trafficType.
88
* It uses the 'useContext' hook to access the context, which is updated by SplitFactory and SplitClient components in the hierarchy of components.
99
*
1010
* @return A Split Context object
1111
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#advanced-instantiate-multiple-sdk-clients}
1212
*/
13-
export function useClientAndContext(key?: SplitIO.SplitKey, trafficType?: string, attributes?: SplitIO.Attributes): ISplitContextValues {
13+
export function useSplitClient(key?: SplitIO.SplitKey, trafficType?: string, attributes?: SplitIO.Attributes): ISplitContextValues {
1414
if (!checkHooks(ERROR_UC_NO_USECONTEXT)) return INITIAL_CONTEXT;
1515

1616
const context = React.useContext(SplitContext);
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ import { getControlTreatmentsWithConfig, ERROR_UT_NO_USECONTEXT } from './consta
22
import { checkHooks, IClientWithContext } from './utils';
33
import { ISplitTreatmentsChildProps } from './types';
44
import { INITIAL_CONTEXT } from './SplitContext';
5-
import { useClientAndContext } from './useClientAndContext';
5+
import { useSplitClient } from './useSplitClient';
66

77
/**
8-
* 'useTreatmentsAndContext' is a hook that returns an SplitContext object extended with a `treatments` property containing an object of feature flag evaluations (i.e., treatments).
9-
* It uses the 'useClientAndContext' hook to access the client from the Split context, and invokes the 'getTreatmentsWithConfig' method.
8+
* 'useSplitTreatments' is a hook that returns an SplitContext object extended with a `treatments` property containing an object of feature flag evaluations (i.e., treatments).
9+
* It uses the 'useSplitClient' hook to access the client from the Split context, and invokes the 'getTreatmentsWithConfig' method.
1010
*
1111
* @return A Split Context object extended with a TreatmentsWithConfig instance, that might contain control treatments if the client is not available or ready, or if split names do not exist.
1212
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#get-treatments-with-configurations}
1313
*/
14-
export function useTreatmentsAndContext(splitNames: string[], attributes?: SplitIO.Attributes, key?: SplitIO.SplitKey): ISplitTreatmentsChildProps {
15-
const context = checkHooks(ERROR_UT_NO_USECONTEXT) ? useClientAndContext(key) : INITIAL_CONTEXT;
14+
export function useSplitTreatments(splitNames: string[], attributes?: SplitIO.Attributes, key?: SplitIO.SplitKey): ISplitTreatmentsChildProps {
15+
const context = checkHooks(ERROR_UT_NO_USECONTEXT) ? useSplitClient(key) : INITIAL_CONTEXT;
1616
const client = context.client;
1717
const treatments = client && (client as IClientWithContext).__getStatus().isOperational ?
1818
client.getTreatmentsWithConfig(splitNames, attributes) :

src/useTreatments.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useTreatmentsAndContext } from './useTreatmentsAndContext';
1+
import { useSplitTreatments } from './useSplitTreatments';
22

33
/**
44
* 'useTreatments' is a hook that returns an object of feature flag evaluations (i.e., treatments).
@@ -9,7 +9,7 @@ import { useTreatmentsAndContext } from './useTreatmentsAndContext';
99
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#get-treatments-with-configurations}
1010
*/
1111
const useTreatments = (featureFlagNames: string[], attributes?: SplitIO.Attributes, key?: SplitIO.SplitKey): SplitIO.TreatmentsWithConfig => {
12-
return useTreatmentsAndContext(featureFlagNames, attributes, key).treatments;
12+
return useSplitTreatments(featureFlagNames, attributes, key).treatments;
1313
};
1414

1515
export default useTreatments;
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { ISplitContextValues } from './SplitContext';
22
/**
3-
* 'useClientAndContext' is a hook that returns an Split Context object with the client and its status corresponding to the provided key and trafficType.
3+
* 'useSplitClient' is a hook that returns an Split Context object with the client and status corresponding to the provided key and trafficType.
44
* It uses the 'useContext' hook to access the context, which is updated by SplitFactory and SplitClient components in the hierarchy of components.
55
*
66
* @return A Split Context object
77
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#advanced-instantiate-multiple-sdk-clients}
88
*/
9-
export declare function useClientAndContext(key?: SplitIO.SplitKey, trafficType?: string, attributes?: SplitIO.Attributes): ISplitContextValues;
9+
export declare function useSplitClient(key?: SplitIO.SplitKey, trafficType?: string, attributes?: SplitIO.Attributes): ISplitContextValues;

types/useSplitTreatments.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { ISplitTreatmentsChildProps } from './types';
2+
/**
3+
* 'useSplitTreatments' is a hook that returns an SplitContext object extended with a `treatments` property containing an object of feature flag evaluations (i.e., treatments).
4+
* It uses the 'useSplitClient' hook to access the client from the Split context, and invokes the 'getTreatmentsWithConfig' method.
5+
*
6+
* @return A Split Context object extended with a TreatmentsWithConfig instance, that might contain control treatments if the client is not available or ready, or if split names do not exist.
7+
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#get-treatments-with-configurations}
8+
*/
9+
export declare function useSplitTreatments(splitNames: string[], attributes?: SplitIO.Attributes, key?: SplitIO.SplitKey): ISplitTreatmentsChildProps;

types/useTreatmentsAndContext.d.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)