-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.d.ts
104 lines (85 loc) · 2.77 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import React, { PropsWithChildren } from "react";
import { IFlags } from "flagsmith";
export interface Flagsmith {
/**
* Denotes if Flagsmith is fully initialised and ready
*/
isLoading: boolean;
/**
* Denotes if Flagsmith is in an errored state
*/
isError: boolean;
/**
* Denotes if Flagsmith is evaluating flags for a specific user
*/
isIdentified: boolean;
/**
* Denotes if Flagsmith is listening for changes
*/
isListening: boolean;
/**
* Identify user, triggers a call to get flags if flagsmith.init has been called
*/
identify: (userId: string, traits?: Record<string, string|number|boolean>) => Promise<IFlags | undefined>;
/**
* Clears the identity, triggers a call to getFlags
*/
logout: () => Promise<IFlags>;
/**
* Polls the flagsmith API, specify interval in ms
*/
startListening: (interval?: number) => void;
/**
* Stops polling
*/
stopListening: () => void;
/**
* Determine whether a flag is enabled e.g. flagsmith.hasFeature("powerUserFeature")
*/
hasFeature: (key: string) => boolean;
/**
* Get the value of a particular remote config e.g. flagsmith.getValue("font_size")
*/
getValue: (key: string) => string | number | boolean;
/**
* Attach a callback function that is notified whenever the Flagsmith state
* changes (i.e. new flag evaluations are available)
*/
subscribe: (callback: Function) => void;
/**
* Force a re-evaluation and fetch of flags
*/
getFlags: () => Promise<IFlags>;
/**
* Get the value of a specific trait for the currently identified user
*/
getTrait: (key: string) => string | number | boolean;
/**
* Set the value of a trait for the current user. Triggers a fetch of the flags
*/
setTrait: (key: string, value: string | number | boolean) => Promise<IFlags>;
/**
* Increment the value of a trait for the current user. Triggers a fetch of the flags
*/
incrementTrait: (key: string, incrementBy: number) => Promise<IFlags>;
/**
* Set a key value set of traits for a given user, triggers a fetch of the flags
*/
setTraits: (
traits: Record<string, string | number | boolean>
) => Promise<IFlags>;
}
/**
* Hook function to access Flagsmith functionality
*/
export function useFlagsmith(): Flagsmith;
export declare type FlagsmithProviderProps = PropsWithChildren<{
environmentId: string; // Flagsmith environmentId
flagsmith?: Object; // Optional Flagsmith implementation
asyncStorage?: Object; // Async storage implementation
cacheFlags?: boolean; // Cache flags locally
defaultFlags?: IFlags; // Default flags
preventFetch?: boolean; // Prevent flags from being fetched
api?: string; // Flagsmith api url
}>
export declare function FlagsmithProvider({}: FlagsmithProviderProps): React.ReactElement;