Skip to content
Logo

Other frameworks

@ghostry/finity-core is finity without a framework. Its initialize takes one more option, useState, an adapter over your framework's state, and builds everything else on it:

export const  = ({
  : < extends {}>(: () => ): [<>, <>] => {
    const  = (());
    const  = (:  | ((: ) => )) => {
      const  =  instanceof  ? (.()) : ;
      .();
      return ;
    };
    return [.,  as <>];
  },
});

The adapter receives a function returning the initial value, and returns a pair:

  • a getter returning the current value, read wherever finity reads the state
  • a setter taking a new value, or a function from the previous value to the new one, and returning the value it set

That's the shape of Solid's createSignal, which is all @ghostry/finity-solidjs passes. finity also uses the adapter for its own bookkeeping, so it must return a separate state each time it's called.

What core leaves to you

Core returns defineTransitionalState, both state hooks, useState, and useEffect. Two things are different from the React and Solid packages:

  • useEffect(...).use() runs the matching case immediately, each time it's called. Call it from your framework's own effect, keyed on the state, so it runs once per change.
  • There's no useRender. Rendering belongs to the framework. A switch on kind with never from @ghostry/finity-core in its default checks that every state is handled, or build a render switch on ExhaustiveSwitchInstance and the ExhaustiveSwitch type, as the React and Solid packages do.

To have your framework supported directly, open an issue.