@unleash/proxy-client-vue 1.0.0-beta.1 → 1.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -5
- package/dist/FlagProvider.vue.d.ts +2 -1
- package/dist/index.es.js +402 -394
- package/dist/index.umd.js +1 -2
- package/dist/plugin.d.ts +1 -1
- package/dist/useFlag.d.ts +2 -2
- package/dist/useUnleashProvide.d.ts +5 -3
- package/dist/useVariant.d.ts +3 -3
- package/package.json +9 -3
package/README.md
CHANGED
|
@@ -106,10 +106,9 @@ const client = new UnleashClient(config)
|
|
|
106
106
|
|
|
107
107
|
### Deferring client start
|
|
108
108
|
|
|
109
|
-
By default, the
|
|
109
|
+
By default, `FlagProvider` starts the client when mounted. The plugin starts it when installed.
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
- passing a client instance to the `FlagProvider`
|
|
111
|
+
To control startup yourself, pass a client instance and set `startClient` to `false`:
|
|
113
112
|
|
|
114
113
|
```jsx
|
|
115
114
|
<template>
|
|
@@ -131,7 +130,7 @@ const client = new UnleashClient({
|
|
|
131
130
|
onMounted(() => {
|
|
132
131
|
const asyncProcess = async () => {
|
|
133
132
|
// do async work ...
|
|
134
|
-
client.start()
|
|
133
|
+
await client.start()
|
|
135
134
|
}
|
|
136
135
|
asyncProcess()
|
|
137
136
|
})
|
|
@@ -143,6 +142,12 @@ onMounted(() => {
|
|
|
143
142
|
</template>
|
|
144
143
|
```
|
|
145
144
|
|
|
145
|
+
### Client cleanup and SSR
|
|
146
|
+
|
|
147
|
+
Clients keep running when the provider or app is unmounted. Set `stopClient` to `true` to stop the client on unmount. The component and plugin both accept this option.
|
|
148
|
+
|
|
149
|
+
For SSR, create a separate client for each request and use bootstrap data to render flags on the server. When using the plugin, pass your client with `startClient: false` to avoid starting it during server rendering.
|
|
150
|
+
|
|
146
151
|
## Usage
|
|
147
152
|
|
|
148
153
|
### Check feature toggle status
|
|
@@ -180,6 +185,20 @@ const variant = useVariant('travel.landing')
|
|
|
180
185
|
</template>
|
|
181
186
|
```
|
|
182
187
|
|
|
188
|
+
### Reactive flag names
|
|
189
|
+
|
|
190
|
+
`useFlag` and `useVariant` also accept refs, computed values, and getters. Their values update when the flag name changes:
|
|
191
|
+
|
|
192
|
+
```vue
|
|
193
|
+
<script setup lang="ts">
|
|
194
|
+
import { useFlag, useVariant } from '@unleash/proxy-client-vue'
|
|
195
|
+
|
|
196
|
+
const props = defineProps<{ flagName: string }>()
|
|
197
|
+
const enabled = useFlag(() => props.flagName)
|
|
198
|
+
const variant = useVariant(() => props.flagName)
|
|
199
|
+
</script>
|
|
200
|
+
```
|
|
201
|
+
|
|
183
202
|
### Defer rendering until flags fetched
|
|
184
203
|
|
|
185
204
|
useFlagsStatus retrieves the ready state and error events.
|
|
@@ -224,4 +243,18 @@ watch(userId, () => {
|
|
|
224
243
|
|
|
225
244
|
## Development
|
|
226
245
|
|
|
227
|
-
|
|
246
|
+
Install pnpm, then install dependencies and build the SDK. The packageManager field in package.json pins the pnpm version.
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
pnpm install
|
|
250
|
+
pnpm build
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Dependency install scripts are disabled. Publishing still runs prepare to build the package.
|
|
254
|
+
|
|
255
|
+
| Command | Purpose |
|
|
256
|
+
| --- | --- |
|
|
257
|
+
| `pnpm run check` | Type-check the source and runtime tests. |
|
|
258
|
+
| `pnpm test` | Run the component, plugin, and composable tests. |
|
|
259
|
+
| `pnpm build` | Build the SDK and its TypeScript declarations. |
|
|
260
|
+
| `pnpm test:package` | Build and pack the SDK, then check its types, browser build, imports, and SSR in an isolated consumer. |
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { UnleashClient, IConfig } from 'unleash-proxy-client';
|
|
1
|
+
import type { UnleashClient, IConfig } from 'unleash-proxy-client';
|
|
2
2
|
type __VLS_Props = {
|
|
3
3
|
config?: IConfig;
|
|
4
4
|
unleashClient?: UnleashClient;
|
|
5
5
|
startClient?: boolean;
|
|
6
|
+
stopClient?: boolean;
|
|
6
7
|
};
|
|
7
8
|
declare const __VLS_template: () => {
|
|
8
9
|
__VLS_Slots: {
|