FirebaseExtended / FirebaseExtended/reactfire

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

Aperta
#511 0 commenti 1 reazione 1 assegnatario Rivendicata da @HYACCCINT Vedi su GitHub
feature request v5
Lingua principale
TypeScript
Stelle
3.6k
Fork
403
Merge medio
14h 53m
PR unite (30g)
5

Descrizione

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

## Current usage
```ts
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
```ts
interface MyAwesomeRemoteConfigParameter {
buttonColor: "blue" | "red";
autoDestruction: boolean;
}

const {data: myParam} = useRemoteConfigValue("my_awesome_remote_config_parameter");
// myParam is parsed with MyAwesomeRemoteConfigParameter interface
```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.