https://github.com/herp-inc/cycle-launchdarkly-driver
LaunchDarkly driver for Cycle.js, based on fp-ts and io-ts
https://github.com/herp-inc/cycle-launchdarkly-driver
cyclejs launchdarkly
Last synced: 3 months ago
JSON representation
LaunchDarkly driver for Cycle.js, based on fp-ts and io-ts
- Host: GitHub
- URL: https://github.com/herp-inc/cycle-launchdarkly-driver
- Owner: herp-inc
- Created: 2022-02-10T09:38:29.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-03-25T05:42:20.000Z (4 months ago)
- Last Synced: 2025-04-27T00:18:46.231Z (3 months ago)
- Topics: cyclejs, launchdarkly
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@herp-inc/cycle-launchdarkly-driver
- Size: 761 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `@herp-inc/cycle-launchdarkly-driver` [](https://www.npmjs.com/package/@herp-inc/cycle-launchdarkly-driver)
[LaunchDarkly](https://launchdarkly.com/) driver for [Cycle.js](https://cycle.js.org/), based on [Standard Schema
](https://standardschema.dev/).## Installation
Note that the following packages are peer dependencies of this library, which need to be installed separately.
| Package | Version |
| ---------------------------------------------------------------------------------------- | ------- |
| [`launchdarkly-js-client-sdk`](https://www.npmjs.com/package/launchdarkly-js-client-sdk) | `3` |
| [`xstream`](https://www.npmjs.com/package/xstream) | `11` |```sh
$ yarn add @herp-inc/cycle-launchdarkly-driver
```## Example
```typescript
import { run } from '@cycle/run';
import { makeDOMDriver } from '@cycle/dom';
import { makeLaunchDarklyDriver } from '@herp-inc/cycle-launchdarkly-driver';
import * as z from 'zod';type Features = {
foo: boolean;
bar: number;
baz: string;
};const Features = {
schema: z.object({
foo: z.boolean(),
bar: z.number(),
baz: z.string(),
}),
defaultValues: {
foo: false,
bar: 0,
baz: '',
},
};type Sources = { features: FeaturesSource };
type Sinks = { DOM: Stream };function main({ features }: Sources): Sinks {
return {
DOM: features.stream.map(view),
};
}const drivers = {
features: makeLaunchDarklyDriver({
envKey: YOUR_CLIENT_SIDE_ID,
defaultValues: FeatureFlags.defaultValues,
fallbackDelay: 100,
options: {
bootstrap: 'localStorage',
},
schema: FeatureFlags.schema,
user: {
key: user.id,
},
}),
DOM: makeDOMDriver('#app'),
};run(main, drivers);
```