How to use the @splitsoftware/splitio.SplitFactory function in @splitsoftware/splitio

To help you get started, we’ve selected a few @splitsoftware/splitio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github splitio / javascript-client / ts-tests / index.ts View on Github external
},
  storage: {
    type: 'REDIS'
  }
};
// For browser
browserSettings = {
  core: {
    authorizationKey: 'another-key',
    key: 'customer-key'
  }
};
// With sync settings should return ISDK, if settings have async storage it should return IAsyncSDK
SDK = SplitFactory(browserSettings);
SDK = SplitFactory(nodeSettings);
AsyncSDK = SplitFactory(asyncSettings);

// The settings values the SDK expose.
const instantiatedSettingsCore: {
  authorizationKey: string,
  key: SplitIO.SplitKey,
  trafficType: string,
  labelsEnabled: boolean,
  IPAddressesEnabled: boolean
} = SDK.settings.core;
const instantiatedSettingsMode: ('standalone' | 'consumer') = SDK.settings.mode;
const instantiatedSettingsScheduler: {[key: string]: number} = SDK.settings.scheduler;
const instantiatedSettingsStartup: {[key: string]: number} = SDK.settings.startup;
const instantiatedSettingsStorage: {
  prefix: string,
  options: Object,
  // It can have any of the storages.
github splitio / javascript-client / ts-tests / index.ts View on Github external
authorizationKey: 'key'
  },
  storage: {
    type: 'REDIS'
  }
};
// For browser
browserSettings = {
  core: {
    authorizationKey: 'another-key',
    key: 'customer-key'
  }
};
// With sync settings should return ISDK, if settings have async storage it should return IAsyncSDK
SDK = SplitFactory(browserSettings);
SDK = SplitFactory(nodeSettings);
AsyncSDK = SplitFactory(asyncSettings);

// The settings values the SDK expose.
const instantiatedSettingsCore: {
  authorizationKey: string,
  key: SplitIO.SplitKey,
  trafficType: string,
  labelsEnabled: boolean,
  IPAddressesEnabled: boolean
} = SDK.settings.core;
const instantiatedSettingsMode: ('standalone' | 'consumer') = SDK.settings.mode;
const instantiatedSettingsScheduler: {[key: string]: number} = SDK.settings.scheduler;
const instantiatedSettingsStartup: {[key: string]: number} = SDK.settings.startup;
const instantiatedSettingsStorage: {
  prefix: string,
  options: Object,
github splitio / javascript-client / ts-tests / index.ts View on Github external
core: {
    authorizationKey: 'key'
  },
  storage: {
    type: 'REDIS'
  }
};
// For browser
browserSettings = {
  core: {
    authorizationKey: 'another-key',
    key: 'customer-key'
  }
};
// With sync settings should return ISDK, if settings have async storage it should return IAsyncSDK
SDK = SplitFactory(browserSettings);
SDK = SplitFactory(nodeSettings);
AsyncSDK = SplitFactory(asyncSettings);

// The settings values the SDK expose.
const instantiatedSettingsCore: {
  authorizationKey: string,
  key: SplitIO.SplitKey,
  trafficType: string,
  labelsEnabled: boolean,
  IPAddressesEnabled: boolean
} = SDK.settings.core;
const instantiatedSettingsMode: ('standalone' | 'consumer') = SDK.settings.mode;
const instantiatedSettingsScheduler: {[key: string]: number} = SDK.settings.scheduler;
const instantiatedSettingsStartup: {[key: string]: number} = SDK.settings.startup;
const instantiatedSettingsStorage: {
  prefix: string,
github tdeekens / flopflip / packages / splitio-adapter / modules / adapter / adapter.ts View on Github external
const initializeClient = (): {
  client: SplitIO.IClient;
  manager: SplitIO.IManager;
} => {
  if (!adapterState.splitioSettings) {
    throw Error(
      'cannot initialize SplitIo without configured settings, call configure() first'
    );
  }

  const sdk = SplitFactory(adapterState.splitioSettings); // eslint-disable-line new-cap

  return {
    client: sdk.client(),
    manager: sdk.manager(),
  };
};
github splitio / split-evaluator / sdk.js View on Github external
logger.info(`SDK_URL: ${process.env.SDK_URL}`);
logger.info(`EVENTS_URL: ${process.env.EVENTS_URL}`);
if (process.env.SPLITIO_IMPRESSION_LISTENER) {
  settings = merge({}, settings, {
    impressionListener: {
      logImpression,
    },
  });
  context.start();
  logger.info(`IMPRESSION_LISTENER: ${process.env.SPLITIO_IMPRESSION_LISTENER}`);
}

let isClientReady = false;

// Our SDK factory instance.
const factory = SplitFactory(settings);
// Our client.
const client = factory.client();
// Our manager.
const manager = factory.manager();
// Returns true if the client is ready.
const isReady = () => isClientReady;

client.on(client.Event.SDK_READY, () => {
  logger.info(`ON SDK_READY, IS CLIENT READY?: ${isClientReady}`);
  return isClientReady === true;
});

module.exports = {
  factory,
  client,
  manager,