Pay attention
This documentation is for the as yet unreleased version of effector Spacewatch 23.0.

createGate

createGate(config?: {defaultState?, domain?, name?})

Creates a Gate, if defaultState is defined, Gate.state will be created with passed value

Arguments

config (Object): Optional configuration object

  • defaultState?: Optional default state for Gate.state
  • domain? ([Domain]/apieffector/Domain)): Optional domain which will be used to create gate units (Gate.open event, Gate.state store and so on)
  • name? (string): Optional name which will be used as name of a created Solid component

Returns

Gate

createGate(name?)

Creates a Gate

Arguments

  1. name? (string): Optional name which will be used as name of a created Solid component

Returns

Gate

Example

import { createGate } from "effector-solid";
import { render } from "solid-js/web";

const Gate = createGate("gate with props");

const App = () => (
  <section>
    <Gate foo="bar" />
  </section>
);

Gate.state.watch((state) => {
  console.log("current state", state);
});
// => current state {}

const unmount = render(() => <App />, document.getElementById("root"));
// => current state {foo: 'bar'}

unmount();
// => current state {}
Contributors