launch.io
Version:
Launch.IO is an Ultra Hip, Simple, and Fast, Time Traveling React State Management Library
50 lines (31 loc) • 1.42 kB
Markdown
Back to [API Reference](./index.md).
---
`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.
`services` **array**
The array of application [Services](./service.md). 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](./timeTravelDebugging.md) 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.
```jsx
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;
```