Skip to content

Latest commit

 

History

History
49 lines (31 loc) · 1.39 KB

File metadata and controls

49 lines (31 loc) · 1.39 KB

Launch.IO Logo initializeLaunch

Back to API Reference.


initializeLaunch is a function that is used to initialize your React application with Launch.IO. It should be called before your application is first rendered.

Props

services array

The array of application Services. Each service object will consist of name (string), initialState (object), and actions (object) properties.

options object

Contains the Launch.IO configuration properties:

  • enableTimeTravel (boolean) indicates whether or not time travel debugging is enabled. This has a default value of false and it should not be enabled in non-development environments.

  • timeTravelHistoryLimit (number) indicates how many time travel actions are stored in history. This has a default value of 50.

Example

import React from "react";
import { initializeLaunch } from "launch.io";

const calculatorService = {
  name: "calculator",

  initialState: {
    value: 0,
  },

  actions: {
    increase: ({ state }, payload) => ({ value: state.value + payload }),
    decrease: ({ state }, payload) => ({ value: state.value - payload }),
  },
};

initializeLaunch([calculatorService], { enableTimeTravel: true });

const App = () => {
  return <div className="MyApp">...</div>;
};

export default App;