solid-signals@1.5.0
Repository
Current version released
2 years ago
Versions
- solid-u@0.1.3Latest
- solid-u@0.1.2
- solid-u@0.1.1
- solid-signals@1.6.1
- solid-signals@1.6.0
- solid-u@0.1.0
- solid-u@0.0.11
- solid-u@0.0.10
- solid-u@0.0.9
- solid-u@0.0.8
- solid-u@0.0.7
- solid-u@0.0.6
- solid-signals@1.5.5
- solid-signals@1.5.4
- solid-signals@1.5.3
- solid-signals@1.5.2
- solid-signals@1.5.1
- solid-signals@1.5.0
- solid-u@0.0.5
- solid-signals@1.4.5
- solid-signals@1.4.4
- solid-signals@1.4.3
- solid-signals@1.4.2
- solid-signals@1.4.1
- solid-u@0.0.4
- solid-signals@1.4.0
- solid-signals@1.3.10
- solid-u@0.0.3
- solid-u@0.0.2
- solid-u@0.0.1
- solid-signals@1.3.9
- solid-signals@1.3.8
- solid-signals@1.3.7
- solid-signals@1.3.6
- solid-signals@1.3.5
- solid-signals@1.3.4
- solid-signals@1.3.3
- solid-signals@1.3.2
- solid-signals@1.3.1
- solid-signals@1.3.0
- solid-signals@1.2.6
- solid-signals@1.2.5
- solid-signals@1.2.4
- solid-signals@1.2.3
- solid-signals@1.2.2
- solid-signals@1.2.1
- solid-signals@1.2.0
- solid-signals@1.1.0
- solid-signals@1.0.2
Solid Signals
Composable signals for SolidJS
All composable signals will extend the base SolidJS signal API by adding properties to accessors and setters, all fully typed.
Installation
$ npm install solid-signals
Usage
Basic
This example uses createHistory
, see other signals in the Signals section
const [state, setState] = createHistory(0);
state(); // => 0
// Accessor extension
state.history(); // => [0]
setState(1);
state(); // => 1
state.history(); // => [0, 1]
// Setter extension
setState.history.back();
state(); // => 0
state.history(); // => [0]
setState.history.forward();
state(); // => 1
state.history(); // => [0, 1]
Composition
Signal composition is achieved by wrapping other signals with the .wrap
method. This allows you to extend a signal with as many features as you’d like instead of using a single feature set provided by a traditional signal.
import { createArray, createHistory } from "solid-signals";
const [state, setState] = createHistory.wrap(createArray<number>([]));
// setState.push is provided by createArray
setState.push(1); // state() => [1]
setState.push(1, 2, 3); // state() => [1, 2, 3]
// setState.history.back is provided by createHistory
setState.history.back(); // state() => [1]
// Accessors can also be extended
// state.history is provided by createHistory
state.history(); // => [[], [1]]
Signals
Creating your own composable signal
(This api is not finalized)
You can create your own composable signal by using the signalExtender api, see createObject.ts for an example