@codemaskinc/store
Advanced tools
Comparing version 0.1.3 to 0.1.4
import { FC, PropsWithChildren } from "react"; | ||
export type Synchronizer<T> = { | ||
value: T; | ||
subscribe: (update: (value: T) => void, key: string) => VoidFunction; | ||
subscribe?: (update: (value: T) => void, key: string) => VoidFunction; | ||
getSnapshot: (key: string) => T | Promise<T>; | ||
@@ -29,2 +29,3 @@ update: (value: T, key: string) => void; | ||
effect: <TKeys_2 extends (keyof TStateRaw)[]>(run: (state: { [K_1 in keyof TStateRaw]: TStateRaw[K_1] extends Synchronizer<infer U> ? U : TStateRaw[K_1]; }) => void, deps: [...TKeys_2]) => () => void; | ||
useStoreEffect: <TKeys_3 extends (keyof TStateRaw)[]>(run: (state: { [K_1 in keyof TStateRaw]: TStateRaw[K_1] extends Synchronizer<infer U> ? U : TStateRaw[K_1]; }) => void, deps: [...TKeys_3]) => void; | ||
HydrateStore: FC<PropsWithChildren<{ | ||
@@ -31,0 +32,0 @@ hydrateState: Partial<{ [K_1 in keyof TStateRaw]: TStateRaw[K_1] extends Synchronizer<infer U> ? U : TStateRaw[K_1]; }>; |
@@ -68,3 +68,3 @@ var $8zHUo$fastdeepequal = require("fast-deep-equal"); | ||
if ((0, $9ba0f9a5c47c04f2$export$c000ccc814a70475)(value)) { | ||
value.subscribe(getAction(key), key); | ||
value.subscribe?.(getAction(key), key); | ||
listeners[key].push((newValue)=>value.update(newValue, key)); | ||
@@ -154,2 +154,8 @@ try { | ||
}; | ||
const useStoreEffect = (run, deps)=>{ | ||
(0, $8zHUo$react.useEffect)(()=>{ | ||
const dispose = effect(run, deps); | ||
return dispose; | ||
}, []); | ||
}; | ||
const HydrateStore = ({ hydrateState: hydrateState, children: children })=>{ | ||
@@ -173,2 +179,3 @@ Object.entries(hydrateState).forEach(([key, value])=>{ | ||
effect: effect, | ||
useStoreEffect: useStoreEffect, | ||
HydrateStore: HydrateStore | ||
@@ -175,0 +182,0 @@ }; |
{ | ||
"name": "@codemaskinc/store", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "- ⚛️ updates outside react components - 🪝 easy access to all store values - ✍️ no repeating yourself - ⚡️ no unnecessary rerenders - 🚀 typescript intellisense", | ||
@@ -10,4 +10,4 @@ "source": "src/index.ts", | ||
"keywords": ["state", "react", "store", "context", "rerenders", "typescript", "intellisense"], | ||
"homepage": "https://github.com/codemaskinc/createStore", | ||
"repository": "https://github.com/codemaskinc/createStore", | ||
"homepage": "https://github.com/codemaskinc/store", | ||
"repository": "https://github.com/codemaskinc/store", | ||
"exports": { | ||
@@ -28,3 +28,3 @@ ".": { | ||
"scripts": { | ||
"postinstall": "husky install", | ||
"prepare": "husky", | ||
"precommit": "bun test && bun lint && dprint fmt && git add .", | ||
@@ -53,14 +53,14 @@ "prebuild": "rm -rf dist && rm -rf .parcel-cache", | ||
"@arethetypeswrong/cli": "0.13.5", | ||
"@happy-dom/global-registrator": "12.10.3", | ||
"@parcel/packager-ts": "2.10.3", | ||
"@parcel/transformer-typescript-types": "2.10.3", | ||
"@testing-library/react": "14.1.2", | ||
"@happy-dom/global-registrator": "13.3.8", | ||
"@parcel/packager-ts": "2.11.0", | ||
"@parcel/transformer-typescript-types": "2.11.0", | ||
"@testing-library/react": "14.2.1", | ||
"@types/bun": "1.0.0", | ||
"@types/node": "20.10.6", | ||
"@types/node": "20.11.18", | ||
"@types/react": "18.2.46", | ||
"@types/use-sync-external-store": "0.0.6", | ||
"@types/web": "0.0.134", | ||
"@typescript-eslint/eslint-plugin": "6.17.0", | ||
"@typescript-eslint/eslint-plugin-tslint": "6.17.0", | ||
"@typescript-eslint/parser": "6.17.0", | ||
"@typescript-eslint/eslint-plugin": "7.0.1", | ||
"@typescript-eslint/eslint-plugin-tslint": "7.0.1", | ||
"@typescript-eslint/parser": "7.0.1", | ||
"dprint": "0.45.0", | ||
@@ -71,3 +71,3 @@ "eslint": "8.56.0", | ||
"eslint-plugin-import": "2.29.1", | ||
"eslint-plugin-jsdoc": "48.0.2", | ||
"eslint-plugin-jsdoc": "48.1.0", | ||
"eslint-plugin-jsx-a11y": "6.8.0", | ||
@@ -80,4 +80,4 @@ "eslint-plugin-nested-if": "1.0.0", | ||
"eslint-plugin-react-hooks": "4.6.0", | ||
"husky": "8.0.3", | ||
"parcel": "2.10.3", | ||
"husky": "9.0.11", | ||
"parcel": "2.11.0", | ||
"publint": "0.2.7", | ||
@@ -84,0 +84,0 @@ "type-testing": "0.2.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
64415
467
0