meiosis-setup Documentation

Installation ⬆ Contents Initial State

Patches

In the Meiosis Documentation, the Meiosis pattern is setup up either with Function Patches or Mergerino. The idea is that using Function Patches gives you the option of having one less library dependency.

On the other hand, meiosis-setup takes a "ready-to-use" approach and includes Mergerino as a dependency. Since Mergerino handles Function Patches, there is no need to choose between the two when setting up Meiosis with meiosis-setup. You can use Function Patches and/or Mergerino as you please:

import { meiosisSetup } from 'meiosis-setup';

interface State {
  // your application state type
}

const cells = meiosisSetup<State>();
cells().update(...); // Function Patch or Mergerino works

State Type

Since we are using TypeScript, we'll want to define a type for our application state to get the most out of what TypeScript offers.

Let's say we have a State type as shown below:

interface State {
  name: string;
  age: number;
}

Then, after setting up Meiosis:

import { meiosisSetup } from 'meiosis-setup';

const cells = meiosisSetup<State>();

const cell = cells();

We now have a stream of cells with each cell having state of type State and having update taking patches that must be compatible with State.

As mentioned earlier, both Function Patches and Mergerino work to update the state.

In the example below, you can experiment with TypeScript support. Try the following:

Installation ⬆ Contents Initial State

Meiosis is developed by foxdonut (Twitter / GitHub) and is released under the MIT license.