codedbychavez / configcat-vue

Vue.js SDK for ConfigCat Feature Flags (community maintained)
https://configcat.com/docs/sdk-reference/community/vue/
3 stars 1 forks source link

Composition API #15

Closed bmulholland closed 7 months ago

bmulholland commented 9 months ago

Sometimes I need to check values in JS instead of HTML. In that case, using the composition API would be nice. Here's some code I wrote for my own version of a responsive value, maybe something like this could work?

    isEnabled(key, defaultValue, options) {
      const returnValue = ref(defaultValue)

      if (!configCatClient) return returnValue

      configCatClient
        .getValueAsync(key, false, options.user)
        .then((value) => {
          returnValue.value = value
        })
        .catch((error) => {
          captureException(error)
        })

      return returnValue
    },
codedbychavez commented 9 months ago

Hi @bmulholland Thank you so much for raising this. I'll have a look and keep you posted here.

codedbychavez commented 7 months ago

Hey @bmulholland, sorry for my late reply. Here's a link to what you may need: https://configcat.com/docs/sdk-reference/community/vue/#using-the-underlying-configcat-client