mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
feat(onboarding): Vue and Svelte snippets (#8250)
This commit is contained in:
parent
e20ef56374
commit
2292e2f6ca
@ -5,18 +5,37 @@ npm install @unleash/proxy-client-svelte
|
||||
|
||||
2\. Initialize Unleash
|
||||
```svelte
|
||||
<script lang="ts">
|
||||
import { FlagProvider } from '@unleash/proxy-client-svelte';
|
||||
<script>
|
||||
import { FlagProvider } from '@unleash/proxy-client-svelte';
|
||||
|
||||
const config = {
|
||||
const config = {
|
||||
url: '<YOUR_API_URL>',
|
||||
clientKey: '<YOUR_API_TOKEN>',
|
||||
refreshInterval: 15,
|
||||
appName: 'unleash-onboarding-svelte'
|
||||
};
|
||||
refreshInterval: 5,
|
||||
metricsInterval: 5,
|
||||
};
|
||||
</script>
|
||||
|
||||
<FlagProvider {config}>
|
||||
<App />
|
||||
</FlagProvider>
|
||||
<div class="app">
|
||||
<FlagProvider {config}>
|
||||
<main>
|
||||
<slot />
|
||||
</main>
|
||||
</FlagProvider>
|
||||
</div>
|
||||
```
|
||||
|
||||
3\. Check feature flag status
|
||||
```svelte
|
||||
<script lang="ts">
|
||||
import { useFlag } from '@unleash/proxy-client-svelte';
|
||||
const enabled = useFlag('<YOUR_FLAG>');
|
||||
</script>
|
||||
|
||||
<section>
|
||||
<p>
|
||||
{$enabled ? 'Feature is enabled!' : 'Feature is disabled!'}
|
||||
</p>
|
||||
</section>
|
||||
```
|
||||
|
@ -4,21 +4,36 @@ npm install @unleash/proxy-client-vue
|
||||
```
|
||||
|
||||
2\. Initialize Unleash
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { FlagProvider } from '@unleash/proxy-client-vue'
|
||||
|
||||
```js
|
||||
import { createApp } from 'frontend/src/component/onboarding/dialog/snippets/vue'
|
||||
import { plugin as unleashPlugin } from '@unleash/proxy-client-vue'
|
||||
// import the root component App from a single-file component.
|
||||
import App from './App.vue'
|
||||
const config = {
|
||||
url: '<YOUR_API_URL>',
|
||||
clientKey: '<YOUR_API_TOKEN>',
|
||||
appName: 'unleash-onboarding-vue',
|
||||
refreshInterval: 5,
|
||||
metricsInterval: 5,
|
||||
}
|
||||
</script>
|
||||
|
||||
const config = {
|
||||
url: '<YOUR_API_URL>',
|
||||
clientKey: '<YOUR_API_TOKEN>',
|
||||
refreshInterval: 15,
|
||||
appName: 'unleash-onboarding-vue',
|
||||
}
|
||||
|
||||
const app = createApp(App)
|
||||
app.use(unleashPlugin, { config })
|
||||
app.mount('#app')
|
||||
<template>
|
||||
<FlagProvider :config="config">
|
||||
<!-- <YourComponent /> -->
|
||||
</FlagProvider>
|
||||
</template>
|
||||
```
|
||||
|
||||
3\. Check feature flag status
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { useFlag } from '@unleash/proxy-client-vue'
|
||||
const enabled = useFlag('<YOUR_FLAG>')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
{{ enabled ? 'Feature is enabled!' : 'Feature is disabled!' }}
|
||||
</div>
|
||||
</template>
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user