Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@harnessio/ff-react-native-client-sdk

Package Overview
Dependencies
Maintainers
4
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@harnessio/ff-react-native-client-sdk

Harness CF React Native SDK ======================== ## Overview

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
18
increased by20%
Maintainers
4
Weekly downloads
 
Created
Source

Harness CF React Native SDK

Overview


Harness is a feature management platform that helps teams to build better software and to test features quicker.


Setup

To install SDK, declare a dependency to project's package.json file:

"ff-react-native-client-sdk": "0.0.1",

Or using npm install:

$ npm install --save ff-react-native-client-sdk

For iOS, run the following commands from project root folder

$ cd ios
$ pod install

Then, you may import package to your project. The SDK is used via single instance exported from index.d.ts module

import cfClientInstance from 'ff-react-native-client-sdk';

Initialization

cfClientInstance is base instance that provides all the features of SDK. It is initialized with instances of CfConfiguration and CfTarget. All configuration fields are optional and if omitted they will be populated with default values by SDK.

import cfClientInstance, {CfConfiguration, CfTarget} from 'ff-react-native-client-sdk';

const client = cfClientInstance;

const cfConfiguration = new CfConfiguration();
cfConfiguration.streamEnabled = true;

const cfTarget = new CfTarget();
cfTarget.identifier = 'Harness'

const apiKey = "YOUR_API_KEY";

const result = await cfClientInstance.initialize(apiKey, cfConfiguration, cfTarget);

cfTarget represents a desired target for which we want features to be evaluated. identifier is mandatory field.

"YOUR_API_KEY" is an authentication key, needed for access to Harness services.

Your Harness SDK is now initialized. Congratulations!!!

Public API Methods

The Public API exposes a few methods that you can utilize:

  • async initialize(apiKey: string, config: CfConfiguration, target:CfTarget)

  • boolVariation(evalutionId: string, defaultValue?: boolean)

  • stringVariation(evalutionId: string, defaultValue?:string)

  • numberVariation(evalutionId: string, defaultValue?:number)

  • jsonVariation(evalutionId: string, defaultValue: any)

  • registerEventsListener(listener: (type: string, flags: any) => void)

  • unregisterListener(listener: (type: string, flags: any) => void)

  • destroy()

Fetch evaluation's value

It is possible to fetch a value for a given evaluation. Evaluation is performed based on different type. In case there is no evaluation with provided id, the default value is returned.

Use appropriate method to fetch the desired Evaluation of a certain type.

boolVariation(evaluationId: string, defaultValue?: boolean)

//get boolean evaluation
let evaluation = await client.boolVariation("demo_bool_evaluation", false)

numberVariation(evaluationId: string, defaultValue?:number)

//get number evaluation
let numberEvaluation = await client.numberVariation("demo_number_evaluation", 0)

stringVariation(evaluationId: string, defaultValue?:string)

//get string evaluaation
let stringEvaluation = await client.stringVariation("demo_string_evaluation", "default");

jsonVariation(evaluationId: string, defaultValue?: any)

//get json evaluation
let jsonEvaluation = await client.jsonVariation("demo_json_evaluation", {});

Register for events

This method provides a way to register a listener for different events that might be triggered by SDK, indicating specific change in SDK itself.

    client.registerEventsListener((type, flags) => {

    });

Each type will return a corresponding value as shown in the table below.

event typereturns
"start"null
"end"null
"evaluation_polling"List
"evaluation_change"EvaluationResponse


Visit documentation for complete list of possible types and values they provide.

To avoid unexpected behaviour, when listener is not needed anymore, a caller should call client.unregisterListener(eventsListener) This way the sdk will remove desired listener from internal list.

Shutting down the SDK

To avoid potential memory leak, when SDK is no longer needed (when the app is closed, for example), a caller should call this method

client.destroy()

FAQs

Package last updated on 17 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc