@statx/core
Advanced tools
+3
-3
| { | ||
| "name": "@statx/core", | ||
| "version": "1.0.20", | ||
| "version": "1.0.21", | ||
| "private": false, | ||
@@ -45,3 +45,3 @@ "description": "Extry tiny smart state manager", | ||
| "build:types": "tsc", | ||
| "demo": "parcel --target=demo", | ||
| "demo": "parcel --target=demo --port=4444", | ||
| "dev": "parcel watch", | ||
@@ -71,3 +71,3 @@ "test": "tsx src/index.test.ts" | ||
| }, | ||
| "gitHead": "62673cc79ed70a117903fa5adfed62dacfcd794b" | ||
| "gitHead": "d8792ab9683c4bbd679aec3c62803f855c62d082" | ||
| } |
+5
-5
@@ -41,4 +41,4 @@ import { | ||
| const cursorHistory = state.historyCursor | ||
| state.history[cursorHistory] = value | ||
| state.historyCursor = (cursorHistory + 1) % state.history.length | ||
| state.history[state.historyCursor] = value | ||
| } | ||
@@ -253,3 +253,3 @@ | ||
| history: Array.from({length: settings.historyLength}), | ||
| historyCursor: 0, | ||
| historyCursor: -1, | ||
| name: getName(options?.name), | ||
@@ -287,3 +287,3 @@ subscribes: new Set(), | ||
| history: Array.from({length: settings.historyLength}), | ||
| historyCursor: 0, | ||
| historyCursor: -1, | ||
| initial: options?.initial as ReturnType<typeof value> | undefined, | ||
@@ -324,5 +324,5 @@ isComputing: false, | ||
| }, | ||
| name: getName(options.name), | ||
| onAction: options.onAction, | ||
| name: getName(options?.name), | ||
| onAction: options?.onAction, | ||
| } | ||
| } |
+1
-16
@@ -39,19 +39,4 @@ import {state, computed} from '../core.js' | ||
| const subscriptions = async () => { | ||
| const s1 = state(0, {name: 's1'}) | ||
| const s2 = state(2, {name: 's2'}) | ||
| const c2 = computed(() => s1() + 10, {name: 'c2'}) | ||
| const c3 = computed(() => s1() + c2() + s2(), {name: 'c3'}) | ||
| const _c3 = () => s1() + s1() + 10 + s2() | ||
| let test = 0 | ||
| c3.subscribe((v) => { | ||
| console.log('Значение при подписке', v) | ||
| test = v | ||
| }) | ||
| s1.set(10) | ||
| s2.set(6) | ||
| s2.set(1) | ||
| s2.set(2) | ||
| await 1 | ||
| console.log(c3, test, c3(), c3() === _c3()) | ||
| console.log(state(0)()) | ||
| } | ||
| subscriptions() |
92909
-0.45%768
-1.92%