0.0.15 • Published 2 years ago

msig v0.0.15

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

msig

The tiny expressive universal signals library you wish you had but only discovered now.

This is a port of the Solid.js Signals API you can use anywhere.

Installation

npm add msig

Usage

You can use the library in a similar (not exactly the same) way to the Solid.js API.

import { createSignal, createMemo } from "msig";

const [a, setA] = createSignal(3);
const [b, setB] = createSignal(4);

const total = createMemo(() => a() * b());

createEffect(() => {
  console.log(total());
}); // logs -> "12"

setA(4); // logs -> "16"
setB(2); // logs -> "8"

Once you have created your reactive system you can expose the output signals using the adaptor for your platform of choice. Here is an example for React:

import React from "react";
import { createSignal, useSignal } from "msig";

// Note the following is in "global" scope
const [count, setCount] = createSignal(0);

function increment() {
  setCount((c) => c + 1);
}

function decrement() {
  setCount((c) => c - 1);
}

export function Counter() {
  const countSig = useSignal(count);
  return (
    <div>
      <div>{countSig}</div>
      <button onChange={increment}>+</button>
      <button onChange={decrement}>-</button>
    </div>
  );
}

Features

The following solid.js reactive primitives have been implemented

  • createSignal
  • createEffect
  • createMemo
  • createResource

Adaptors

Adaptors have been created for:

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago