Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 1 month 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 (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-04-13T10:26:45.000Z (9 months ago)
- Last Synced: 2024-04-14T06:46:03.112Z (8 months ago)
- Topics: cyclejs, launchdarkly
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@herp-inc/cycle-launchdarkly-driver
- Size: 570 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `@herp-inc/cycle-launchdarkly-driver` [![npm](https://img.shields.io/npm/v/@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 [fp-ts](https://gcanti.github.io/fp-ts/) and [io-ts](https://gcanti.github.io/fp-ts/)
## Installation
Note that the following packages are peer dependencies of this library, which need to be installed separately.
| Package | Version |
| ---------------------------------------------------------------------------------------- | ------- |
| [`fp-ts`](https://www.npmjs.com/package/fp-ts) | `^2.11` |
| [`io-ts`](https://www.npmjs.com/package/io-ts) | `^2.2` |
| [`launchdarkly-js-client-sdk`](https://www.npmjs.com/package/launchdarkly-js-client-sdk) | `2` |
| [`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 t from 'io-ts/Decoder';type Features = {
foo: boolean;
bar: number;
baz: string;
};const Features = {
decoder: t.type({
foo: t.boolean,
bar: t.number,
baz: t.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,
decoder: FeatureFlags.decoder,
defaultValues: FeatureFlags.defaultValues,
fallbackDelay: 100,
options: {
bootstrap: 'localStorage',
},
user: {
key: user.id,
},
}),
DOM: makeDOMDriver('#app'),
};run(main, drivers);
```