mirror of https://github.com/open-feature/cli.git
37 lines
1.5 KiB
Cheetah
37 lines
1.5 KiB
Cheetah
'use client';
|
|
|
|
import {
|
|
type ReactFlagEvaluationOptions,
|
|
type ReactFlagEvaluationNoSuspenseOptions,
|
|
useFlag,
|
|
useSuspenseFlag,
|
|
JsonValue
|
|
} from "@openfeature/react-sdk";
|
|
{{ range .Flagset.Flags }}
|
|
/**
|
|
* {{ .Description }}
|
|
*
|
|
* **Details:**
|
|
* - flag key: `{{ .Key }}`
|
|
* - default value: `{{ if eq (.Type | OpenFeatureType) "object"}}{{ .DefaultValue | ToJSONString }}{{ else }}{{ .DefaultValue }}{{ end }}`
|
|
* - type: `{{ if eq (.Type | OpenFeatureType) "object" }}JsonValue{{ else }}{{ .Type | OpenFeatureType }}{{ end }}`
|
|
*/
|
|
export const use{{ .Key | ToPascal }} = (options?: ReactFlagEvaluationOptions) => {
|
|
return useFlag({{ .Key | Quote }}, {{ if eq (.Type | OpenFeatureType) "object"}}{{ .DefaultValue | ToJSONString }}{{ else }}{{ .DefaultValue | QuoteString }}{{ end }}, options);
|
|
};
|
|
|
|
/**
|
|
* {{ .Description }}
|
|
*
|
|
* **Details:**
|
|
* - flag key: `{{ .Key }}`
|
|
* - default value: `{{ if eq (.Type | OpenFeatureType) "object"}}{{ .DefaultValue | ToJSONString }}{{ else }}{{ .DefaultValue }}{{ end }}`
|
|
* - type: `{{ if eq (.Type | OpenFeatureType) "object" }}JsonValue{{ else }}{{ .Type | OpenFeatureType }}{{ end }}`
|
|
*
|
|
* Equivalent to useFlag with options: `{ suspend: true }`
|
|
* @experimental — Suspense is an experimental feature subject to change in future versions.
|
|
*/
|
|
export const useSuspense{{ .Key | ToPascal }} = (options?: ReactFlagEvaluationNoSuspenseOptions) => {
|
|
return useSuspenseFlag({{ .Key | Quote }}, {{ if eq (.Type | OpenFeatureType) "object"}}{{ .DefaultValue | ToJSONString }}{{ else }}{{ .DefaultValue | QuoteString }}{{ end }}, options);
|
|
};
|
|
{{ end}} |