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

Expose feature flags directly #25

Closed
marvinhagemeister opened this issue Oct 8, 2020 · 3 comments
Closed

Expose feature flags directly #25

marvinhagemeister opened this issue Oct 8, 2020 · 3 comments
Assignees

Comments

@marvinhagemeister
Copy link

In my application I make a request upfront to load all feature flags. For as long as the fetch request is in progress, my code falls back to default values. But I can't find an API to just grab all feature flags at once. Instead I have to resort to manually grabbing of the flags:

// Have to manually pull of all keys and iterate over them to get all values :(
const keys = await client.getAllKeysAsync()
const values = await Promise.all(
  keys.map(key => client.getValueAsync(key, undefined, user))
);

const flags = keys.reduce((acc, key, i) => {
  acc[key] = values[i]
  return acc
}, {})

I'd like to get rid of that. Peeking at the code in this repo and configcat/common-js it seems like the data is all there, it's just not exposed. Is there a way to just get the record of the flags directly?

@endret
Copy link
Contributor

endret commented Oct 14, 2020

hi @marvinhagemeister ,

It is right the data is present but the client has to evaluate each of them (it's more than return your feature flag values only). Your code is good solution for this but in this case I suggest to ensure your up to date feature flags with force refresh like this:

await client.forceRefreshAsync()
const keys = await client.getAllKeysAsync()
...

If you choose a proper polling mode client fetches the flags only once (client uses cache)!

Cheers,
Endre

@endret endret self-assigned this Nov 16, 2020
@endret
Copy link
Contributor

endret commented Dec 5, 2020

Hi,

I would like to kindly inform you that in the next release we'll introduce a new function getAllValues (returns all values of a feature flag or setting). This will be an explicit solution to your issue.

Thanks,
Endre

@endret endret closed this as completed Dec 5, 2020
@marvinhagemeister
Copy link
Author

Happy to hear that 👍

This issue was closed.
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