0.3.0 • Published 2 years ago

@herp-inc/cycle-launchdarkly-driver v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@herp-inc/cycle-launchdarkly-driver npm

LaunchDarkly driver for Cycle.js, based on fp-ts and io-ts

Installation

Note that the following packages are peer dependencies of this library, which need to be installed separately.

PackageVersion
fp-ts^2.11
io-ts^2.2
launchdarkly-js-client-sdk2
xstream11
$ yarn add @herp-inc/cycle-launchdarkly-driver

Example

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<Features> };
type Sinks = { DOM: Stream<VNode> };

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);
0.3.0

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago