0.8.0 • Published 1 year ago
@iniz/core v0.8.0
Iniz
Iniz is a reactive state library. Try it out on our website!
npm i @iniz/core
Guide
Getting started
Create an atom
Atom is the smallets unit of reactive state.
import { atom } from "@iniz/core";
const timer$ = atom(new Date());
// It can be a complex nested object/array as well...
const nestedCounter$ = atom({
obj: {
array: [{ count: 3 }],
message: "Hello World",
},
});
Mutate the atom value
Call the atom to read/write it.
timer$(); // Returns latest value e.g. `2019-08-31T00:00:00.000Z`
setInterval(() => {
nestedCounter$().obj.array[0].count++;
timer$(new Date());
// Calling it as function also sets `value`
}, 1000);
// Later on...
timer$(); // Returns latest value e.g. `2022-08-31T00:00:00.000Z`
nestedCouner$().obj.array[0].count;
Subscribe to atom
Use effect()
to subscribe to value change.
const dispose = effect(() => {
console.log("Updated timer: ", timer$());
});
// Execute `dispose` to stop effect
dispose();
Use computed()
to get calculated value from multiple atoms.
const timerAndCounter$ = computed(
() => `Computed: '${nestedCounter$().obj.array[0]}' '${timer$()}'`
);
timerAndCounter$(); // Returns "Computed: 2022-08-31T00:00:00.000Z 4"
0.8.0
1 year ago
0.0.0-20221106155550
2 years ago
0.0.0-20221106154403
2 years ago
0.7.2
2 years ago
0.7.3
2 years ago
0.0.0-20221104162434
2 years ago
0.0.0-20221104161036
2 years ago
0.0.0-20221104160649
2 years ago
0.0.0-20221104160458
2 years ago
0.0.0-20221104155813
2 years ago
0.0.0-20221104155315
2 years ago
0.0.0-20221104154917
2 years ago
0.0.0-20221104154408
2 years ago
0.0.0-20221104153754
2 years ago
0.0.0-20221104153042
2 years ago
0.0.0-20221104152135
2 years ago
0.0.0-20221104150630
2 years ago
0.0.0-20221104145213
2 years ago
0.0.0-20221104141745
2 years ago
0.0.0-20221104141224
2 years ago
0.0.0-20221104133527
2 years ago
0.0.0-20221104133255
2 years ago
0.0.0-20221104095824
2 years ago
0.0.0-20221104095537
2 years ago
0.7.1
2 years ago
0.7.0
2 years ago
0.6.0
2 years ago
0.5.0
2 years ago
0.4.0
2 years ago
0.3.1
2 years ago
0.3.0
2 years ago
0.2.0
2 years ago
0.1.4
2 years ago
0.1.3
2 years ago
0.1.2
2 years ago
0.1.1
2 years ago
0.1.0
2 years ago