Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Using a remote config value with a generic type #511

Open
louis030195 opened this issue Apr 4, 2022 · 0 comments
Open

[FEATURE] Using a remote config value with a generic type #511

louis030195 opened this issue Apr 4, 2022 · 0 comments
Assignees

Comments

@louis030195
Copy link

louis030195 commented Apr 4, 2022

When using JSON in remote config parameter, we have to parse by ourselves the JSON, could be cleaner with generic type?

Current usage

interface MyAwesomeRemoteConfigParameter {
    buttonColor: "blue" | "red";
    autoDestruction: boolean;
}

const {data: myParamJsonString} = useRemoteConfigString("my_awesome_remote_config_parameter");
const myParam: MyAwesomeRemoteConfigParameter | undefined = myParamJsonString ? 
    JSON.parse(myParamJsonString) :
    undefined;

Desired usage

interface MyAwesomeRemoteConfigParameter {
    buttonColor: "blue" | "red";
    autoDestruction: boolean;
}

const {data: myParam} = useRemoteConfigValue<MyAwesomeRemoteConfigParameter>("my_awesome_remote_config_parameter");
// myParam is parsed with MyAwesomeRemoteConfigParameter interface
@HYACCCINT HYACCCINT self-assigned this Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants