Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

igris

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

igris - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

chunk-EFS5F2XS.mjs

19

index.d.ts
import * as react from 'react';
import react__default, { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from 'react';
import { A as AnyType, I as IgrisMaster, a as ActionsCallback, S as StoreConfig, b as StoreHook, c as StateHook, W as WrappedComponentType } from './types-dQlYaLGX.js';
export { g as ActionsCallbackOptions, e as ActualStorage, P as PersistConfig, d as StateListener, f as WithConnectProps } from './types-dQlYaLGX.js';
import { A as AnyType, I as IgrisMaster, a as ActionsCallback, S as StoreConfig, b as StoreHook, c as StateHook, d as SetStateCallback, W as WrappedComponentType } from './types-B9z_KAnN.js';
export { h as ActionsCallbackOptions, f as ActualStorage, P as PersistConfig, e as StateListener, g as WithConnectProps } from './types-B9z_KAnN.js';

@@ -60,3 +60,3 @@ /**

* }),
* { name: "AppState", persist: { enable: true } }
* { name: "AppState", persist: enablePersist() }
* );

@@ -79,3 +79,2 @@ *

declare const createStore: <T extends Record<AnyType, AnyType>, R extends Record<AnyType, AnyType>>(initialState: T, callback: ActionsCallback<T, R>, config?: StoreConfig<T>) => StoreHook<T, R>;
/**

@@ -175,3 +174,2 @@ * Custom hook for integrating a store with React components.

declare const createState: <T>(initialState: T, config?: StoreConfig<T>) => StateHook<T>;
/**

@@ -193,3 +191,2 @@ * Custom React hook for managing state updates and subscriptions.

*/
type SetStateCallback<T> = (state: T) => void | (() => void);
declare const useAState: <T>(state: IgrisState<T> | StateHook<T> | StoreHook<T, AnyType>) => [T, (value: React.SetStateAction<T>, cb?: SetStateCallback<T>) => void];

@@ -213,3 +210,3 @@

*/
declare const shallowMerge: <T extends object = Record<string, any>>(...objects: T[]) => T;
declare const shallowMerge: <T extends object = Record<string, any>>(...objects: object[]) => object;
/**

@@ -221,3 +218,3 @@ * Deep merges multiple objects into a single target object.

*/
declare const deepMerge: <T extends object = Record<string, any>>(target: T, ...sources: object[]) => T;
declare const deepMerge: <T extends object = Record<string, any>>(target: object, ...sources: object[]) => T;

@@ -229,3 +226,3 @@ /**

readonly useAStore: <T extends Record<AnyType, AnyType> = Record<any, any>, R extends Record<AnyType, AnyType> = Record<any, any>, S = T & R>(store: IgrisStore<T, R> | StoreHook<T, R>, selector?: (state: T & R) => S) => S;
readonly useAState: <T>(state: IgrisState<T> | StateHook<T> | StoreHook<T, AnyType>) => [T, (value: React.SetStateAction<T>, cb?: (state: T) => void | (() => void)) => void];
readonly useAState: <T>(state: IgrisState<T> | StateHook<T> | StoreHook<T, AnyType>) => [T, (value: React.SetStateAction<T>, cb?: SetStateCallback<T>) => void];
readonly IgrisStore: typeof IgrisStore;

@@ -235,4 +232,4 @@ readonly IgrisState: typeof IgrisState;

readonly createState: <T>(initialState: T, config?: StoreConfig<T>) => StateHook<T>;
readonly deepMerge: <T extends object = Record<string, any>>(target: T, ...sources: object[]) => T;
readonly shallowMerge: <T extends object = Record<string, any>>(...objects: T[]) => T;
readonly deepMerge: <T extends object = Record<string, any>>(target: object, ...sources: object[]) => T;
readonly shallowMerge: <T extends object = Record<string, any>>(...objects: object[]) => object;
readonly withConnect: <P extends Record<string, any>, R extends Record<string, any>, Ref = unknown>(WrappedComponent: WrappedComponentType<P, Ref>, stateMap: (props: react.PropsWithoutRef<Omit<P, keyof R>>) => R) => react.ForwardRefExoticComponent<react.PropsWithoutRef<Omit<P, keyof R>> & react.RefAttributes<Ref>>;

@@ -239,0 +236,0 @@ };

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./chunk-RA3I375F.js"),t=require("react"),s=require("use-sync-external-store/shim/with-selector.js");function r(e){return e&&e.__esModule?e:{default:e}}var i=r(t),n=r(s),{useSyncExternalStoreWithSelector:u}=n.default,{useDebugValue:c}=i.default,a=(e,t=e=>e)=>{const s=u(e.subscribe,e.get,e.getServerState,(function(s){return t({...s,...e.actions})}),void 0);return c(s),s},{useSyncExternalStoreWithSelector:o}=n.default,{useDebugValue:h,useCallback:l,useEffect:g,useRef:p}=i.default,S=e=>{const t=p([]),s=o(e.subscribe,e.get,e.getServerState,(e=>e));h(s);const r=l(((s,r)=>{r&&t.current.push(r),e.set(s)}),[e]);return g((()=>{if(t.current.length>0){const e=[...t.current];t.current.length=0;for(const t of e)"function"==typeof t&&t(s)}}),[s]),[s,r]},b=class{constructor(t,s){e.__publicField(this,"listeners"),e.__publicField(this,"currentState"),e.__publicField(this,"persist",null),e.__publicField(this,"fetchCurrentState"),e.__publicField(this,"getServerState"),e.__publicField(this,"initializeValue",(()=>(this.persist&&!this.persist.config.skipHydrate&&this.persist.hydrate(),this.fetchCurrentState=()=>this.currentState,this.currentState))),this.listeners=new Set,this.currentState=t,this.getServerState=()=>this.currentState,this.set=this.set.bind(this),this.subscribe=this.subscribe.bind(this),this.get=this.get.bind(this),this.fetchCurrentState=this.initializeValue,s?.persist&&(s.name?this.persist=s.persist(s.name,this):e.LOG.error("Persist not configured"))}set(e){this.currentState="function"==typeof e?e(this.fetchCurrentState()):e,this.listeners.forEach((e=>e(this.currentState)))}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}get(){return this.fetchCurrentState()}},d=class extends b{constructor(t,s,r){super(t,r),e.__publicField(this,"actions"),this.actions=s({get:this.get.bind(this),set:this.set.bind(this),subscribe:this.subscribe.bind(this)})}},f=(e,t,s)=>{const r=new d(e,t,s),i=e=>a(r,e);return i.persist=r.persist,i.actions=r.actions,i.subscribe=r.subscribe,i.get=r.get,i.set=r.set,i.getServerState=r.getServerState,i},_=class extends b{constructor(t,s){super(t,s),this.persist?.config&&!this.persist.config.merge&&(this.persist.config.merge=(t,s)=>e.isObject(s)&&e.isObject(t)?e.shallowMerge(t,s):s)}},x=(e,t)=>{const s=new _(e,t),r=()=>S(s);return r.subscribe=s.subscribe,r.persist=s.persist,r.get=s.get,r.set=s.set,r.getServerState=s.getServerState,r},w=(s,r)=>{const n=t.forwardRef(((e,t)=>{const n=r(e),u={...e,...n};return i.default.createElement(s,{...u,ref:t})}));return n.displayName=`withIgrisConnect(${e.getDisplayName(s)})`,n},v={useAStore:a,useAState:S,IgrisStore:d,IgrisState:_,createStore:f,createState:x,deepMerge:e.deepMerge,shallowMerge:e.shallowMerge,withConnect:w};Object.defineProperty(exports,"deepMerge",{enumerable:!0,get:function(){return e.deepMerge}}),Object.defineProperty(exports,"shallowMerge",{enumerable:!0,get:function(){return e.shallowMerge}}),exports.IgrisState=_,exports.IgrisStore=d,exports.createState=x,exports.createStore=f,exports.default=v,exports.useAState=S,exports.useAStore=a,exports.withConnect=w;//# sourceMappingURL=index.js.map
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./chunk-GQ37M7T4.js"),t=require("react"),s=require("use-sync-external-store/shim/with-selector.js");function r(e){return e&&e.__esModule?e:{default:e}}var i=r(t),n=r(s),c=class{constructor(t,s){e.__publicField(this,"listeners"),e.__publicField(this,"currentState"),e.__publicField(this,"persist",null),e.__publicField(this,"fetchCurrentState"),e.__publicField(this,"getServerState"),e.__publicField(this,"initializeValue",(()=>(this.persist&&!this.persist.config.skipHydrate&&this.persist.hydrate(),this.fetchCurrentState=()=>this.currentState,this.currentState))),this.listeners=new Set,this.currentState=t,this.getServerState=()=>this.currentState,this.set=this.set.bind(this),this.subscribe=this.subscribe.bind(this),this.get=this.get.bind(this),this.fetchCurrentState=this.initializeValue,s?.persist&&(s.name?this.persist=s.persist(s.name,this):e.LOG.error("Persist not configured"))}set(e){this.currentState="function"==typeof e?e(this.fetchCurrentState()):e,this.listeners.forEach((e=>e(this.currentState)))}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}get(){return this.fetchCurrentState()}},{useSyncExternalStoreWithSelector:u}=n.default,a=class extends c{constructor(t,s,r){super(t,r),e.__publicField(this,"actions"),this.actions=s({get:this.get.bind(this),set:this.set.bind(this),subscribe:this.subscribe.bind(this)})}},o=(e,t,s)=>{const r=new a(e,t,s),i=e=>h(r,e);return i.persist=r.persist,i.actions=r.actions,i.subscribe=r.subscribe,i.get=r.get,i.set=r.set,i.getServerState=r.getServerState,i},h=(e,s=e=>e)=>{const r=u(e.subscribe,e.get,e.getServerState,(function(t){return s({...t,...e.actions})}),void 0);return t.useDebugValue(r),r},{useSyncExternalStoreWithSelector:l}=n.default,g=class extends c{constructor(t,s){super(t,s),this.persist?.config&&!this.persist.config.merge&&(this.persist.config.merge=(t,s)=>e.isObject(s)&&e.isObject(t)?e.shallowMerge(t,s):s)}},p=(e,t)=>{const s=new g(e,t),r=()=>S(s);return r.subscribe=s.subscribe,r.persist=s.persist,r.get=s.get,r.set=s.set,r.getServerState=s.getServerState,r},S=e=>{const s=t.useRef([]),r=l(e.subscribe,e.get,e.getServerState,(e=>e));t.useDebugValue(r);const i=t.useCallback(((t,r)=>{r&&s.current.push(r),e.set(t)}),[e]);return t.useEffect((()=>{if(s.current.length>0){const e=[...s.current];s.current.length=0;for(const t of e)"function"==typeof t&&t(r)}}),[r]),[r,i]},b=(s,r)=>{const n=t.forwardRef(((e,t)=>{const n=r(e),c={...e,...n};return i.default.createElement(s,{...c,ref:t})}));return n.displayName=`withIgrisConnect(${e.getDisplayName(s)})`,n},d={useAStore:h,useAState:S,IgrisStore:a,IgrisState:g,createStore:o,createState:p,deepMerge:e.deepMerge,shallowMerge:e.shallowMerge,withConnect:b};Object.defineProperty(exports,"deepMerge",{enumerable:!0,get:function(){return e.deepMerge}}),Object.defineProperty(exports,"shallowMerge",{enumerable:!0,get:function(){return e.shallowMerge}}),exports.IgrisState=g,exports.IgrisStore=a,exports.createState=p,exports.createStore=o,exports.default=d,exports.useAState=S,exports.useAStore=h,exports.withConnect=b;//# sourceMappingURL=index.js.map
{
"name": "igris",
"version": "1.0.1",
"description": "A small, simple, and type-safe state management solution for React and React Native.",
"version": "1.0.2",
"description": "A lightweight, type-safe state management solution designed to make React state simple",
"main": "index.js",
"module": "index.mjs",
"types": "index.d.ts",
"homepage": "https://github.com/alok-shete/igris#readme",

@@ -47,3 +45,5 @@ "publishConfig": {

"use-sync-external-store": "1.2.0"
}
}
},
"module": "index.mjs",
"types": "index.d.ts"
}
import * as react from 'react';
import react__default, { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from 'react';
import { c as StateHook, A as AnyType, b as StoreHook, h as StorageProvider, H as HydratorProps, W as WrappedComponentType, i as HydratorOption, P as PersistConfig, I as IgrisMaster, j as PersistHandler } from './types-dQlYaLGX.js';
export { k as PersistStorage } from './types-dQlYaLGX.js';
import { c as StateHook, A as AnyType, b as StoreHook, i as StorageProvider, H as HydratorProps, W as WrappedComponentType, j as HydratorOption, P as PersistConfig, I as IgrisMaster, k as PersistHandler } from './types-B9z_KAnN.js';
export { l as PersistStorage } from './types-B9z_KAnN.js';

@@ -16,4 +16,4 @@ declare const setupHydrator: (stores: (StateHook<AnyType> | StoreHook<AnyType, AnyType>)[], config?: {

* @template T The type of the store's state
* @param {Partial<IPersistConfig<T>>} persistConfig The persistence configuration
* @returns {(storeName: string, store: IgrisMaster<T>) => PersistHandler<T>} A function that creates a PersistHandler
* @param persistConfig The persistence configuration
* @returns A function that creates a PersistHandler
*/

@@ -20,0 +20,0 @@ declare const enablePersist: <T>(persistConfig?: Partial<PersistConfig<T>>) => (storeName: string, store: IgrisMaster<T>) => PersistHandler<T>;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./chunk-RA3I375F.js"),t=require("react"),r=require("use-sync-external-store/shim/with-selector.js");function s(e){return e&&e.__esModule?e:{default:e}}var i=s(t),o=s(r),a=class{constructor(t,r,s){e.__publicField(this,"key"),e.__publicField(this,"timeoutId"),e.__publicField(this,"store"),e.__publicField(this,"storage",new e.UninitializedStorage),e.__publicField(this,"unsubscribeStore",(()=>{})),e.__publicField(this,"config"),e.__publicField(this,"subscribeStore",(()=>{this.unsubscribeStore(),this.unsubscribeStore=this.store.subscribe((e=>{this.setItem(e)}))})),this.key=t,this.store=r,this.config={skipHydrate:!1,debounceTime:100,partial:e=>e,...s}}initializeStorage(){const t=e.createJSONStorage(this.config.storage||(()=>localStorage));t&&(this.storage=t)}hydrate(){this.initializeStorage();const t=this.getItem();if(this.subscribeStore(),e.isPromise(t)){const r=e.runImmediately((async()=>{const e=await t;this.store.set(e)}));return this.hydrate=()=>r,r}this.store.currentState=t,this.hydrate=()=>{}}getItem(){const t=this.storage.getItem(this.key)??null;return e.isPromise(t)?e.runImmediately((async()=>{try{return this.processStoredData(await t)}catch(t){return e.LOG.error("Error retrieving stored data:",t),null}})):this.processStoredData(t)}processStoredData(t){if(!t)return this.store.currentState;const{value:r,version:s}=t;let i=r;this.config.version!==s&&this.config.migrate&&(i=this.config.migrate(r,s));return(this.config.merge??e.shallowMerge)(this.store.currentState,i)}setItem(t){clearTimeout(this.timeoutId),this.timeoutId=setTimeout((()=>{const r=this.config.version,s=this.config.partial(t);try{this.storage.setItem(this.key,{value:s,version:r})}catch(t){e.LOG.error("Error setting item",t)}}),this.config.debounceTime)}},{useSyncExternalStoreWithSelector:n}=o.default,u=(t,r)=>()=>{const s=t.map((e=>{if(null==e.persist?.config.storage){if(!e.persist||!r?.storage)return;e.persist.config.storage=r.storage}return e.get(),e.persist?.hydrate()}));if(s.some((e=>e instanceof Promise)))return e.runImmediately((async()=>{await Promise.all(s)}))},c=r=>{const s=t.useRef(void 0),o=t.useRef({isHydrated:!1});return n((e=>(o.current.isHydrated||Promise.resolve(s.current).then((()=>{o.current.isHydrated=!0,e()})),()=>{})),(()=>(null==s.current&&(r.handler?s.current=r.handler():s.current=e.runImmediately(u(r.stores,r.config)),s.current instanceof Promise||(o.current.isHydrated=!0)),o.current.isHydrated)),(()=>o.current.isHydrated),(e=>e))?i.default.createElement(i.default.Fragment,null,r.children):i.default.createElement(i.default.Fragment,null,r.loadingComponent??null)},l=(r,s)=>{const o=t.forwardRef(((e,t)=>i.default.createElement(c,{...s},i.default.createElement(r,{...e,ref:t}))));return o.displayName=`withHydrator(${e.getDisplayName(r)})`,o},d=(e={})=>(t,r)=>new a(t,r,e),h={PersistHandler:a,Hydrator:c,withHydrator:l,setupHydrator:u,enablePersist:d};exports.Hydrator=c,exports.PersistHandler=a,exports.default=h,exports.enablePersist=d,exports.setupHydrator=u,exports.withHydrator=l;//# sourceMappingURL=persistence.js.map
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./chunk-GQ37M7T4.js"),t=require("react"),r=require("use-sync-external-store/shim/with-selector.js");function s(e){return e&&e.__esModule?e:{default:e}}var i=s(t),o=s(r),n=class{constructor(t,r,s){e.__publicField(this,"key"),e.__publicField(this,"timeoutId"),e.__publicField(this,"store"),e.__publicField(this,"storage",new e.UninitializedStorage),e.__publicField(this,"unsubscribeStore",(()=>{})),e.__publicField(this,"config"),e.__publicField(this,"subscribeStore",(()=>{this.unsubscribeStore(),this.unsubscribeStore=this.store.subscribe((e=>{this.setItem(e)}))})),this.key=t,this.store=r,this.config={skipHydrate:!1,debounceTime:100,partial:e=>e,...s}}initializeStorage(){const t=e.createJSONStorage(this.config.storage||(()=>localStorage));t&&(this.storage=t)}hydrate(){this.initializeStorage();const t=this.getItem();if(e.isPromise(t)){const r=e.runImmediately((async()=>{const e=await t;this.store.set(e)}));this.hydrate=()=>r}else this.store.set(t),this.hydrate=()=>{};return this.subscribeStore(),this.hydrate()}getItem(){const t=this.storage.getItem(this.key)??null;return e.isPromise(t)?e.runImmediately((async()=>{try{return this.processStoredData(await t)}catch(t){return e.LOG.error("Error retrieving stored data:",t),null}})):this.processStoredData(t)}processStoredData(t){if(!t)return this.store.currentState;const{value:r,version:s}=t;let i=r;if(this.config.version!==s){if("function"!=typeof this.config.migrate)return this.store.currentState;i=this.config.migrate(r,s)}return(this.config.merge??e.shallowMerge)(this.store.currentState,i)}setItem(t){clearTimeout(this.timeoutId),this.timeoutId=setTimeout((async()=>{const r=this.config.version,s=this.config.partial(t);try{await this.storage.setItem(this.key,{value:s,version:r})}catch(t){e.LOG.error("Error setting item",t)}}),this.config.debounceTime)}},{useSyncExternalStoreWithSelector:a}=o.default,c=(t,r)=>()=>{const s=[];for(const e of t){if(!e.persist)continue;void 0===e.persist.config.storage&&r?.storage&&(e.persist.config.storage=r.storage);const t=e.persist.hydrate();t instanceof Promise&&s.push(t)}if(s.length)return e.runImmediately((async()=>{await Promise.all(s)}))},u=i.default.memo((r=>{const s=t.useRef(void 0),i=t.useRef({isHydrated:!1}),o=t.useCallback((e=>(i.current.isHydrated||Promise.resolve(s.current).then((()=>{i.current.isHydrated=!0,e()})),()=>{})),[]),n=t.useCallback((()=>(void 0===s.current&&(r.handler?s.current=r.handler()??null:s.current=e.runImmediately(c(r.stores,r.config))??null,s.current instanceof Promise||(i.current.isHydrated=!0)),i.current.isHydrated)),[r.handler,r.stores,r.config]),u=a(o,n,n,(e=>e));return t.useMemo((()=>u?r.children:r.loadingComponent??null),[u,r.loadingComponent,r.children])})),l=(r,s)=>{const o=t.forwardRef(((e,t)=>i.default.createElement(u,{...s},i.default.createElement(r,{...e,ref:t}))));return o.displayName=`withHydrator(${e.getDisplayName(r)})`,o},d=(e={})=>(t,r)=>new n(t,r,e),h={PersistHandler:n,Hydrator:u,withHydrator:l,setupHydrator:c,enablePersist:d};exports.Hydrator=u,exports.PersistHandler=n,exports.default=h,exports.enablePersist=d,exports.setupHydrator=c,exports.withHydrator=l;//# sourceMappingURL=persistence.js.map
# Igris
> Igris is a small, simple, and type-safe state management solution for React and React Native. It offers efficient data persistence and seamless integration with various storage mechanisms. Designed to be lightweight and intuitive, Igris helps developers manage application state with ease and confidence.
[![Build Size](https://img.shields.io/bundlephobia/minzip/igris?label=bundle%20size&style=flat&colorA=000000&colorB=000000)](https://bundlephobia.com/result?p=igris)
[![Version](https://img.shields.io/npm/v/igris?style=flat&colorA=000000&colorB=000000)](https://www.npmjs.com/package/igris)
[![Downloads](https://img.shields.io/npm/d18m/igris.svg?style=flat&colorA=000000&colorB=000000)](https://www.npmjs.com/package/igris)
Igris is a small, simple, and type-safe state management solution for React and React Native. It offers efficient data persistence and seamless integration with various storage mechanisms. Designed to be lightweight and intuitive, Igris helps developers manage application state with ease and confidence.
## Features
- **Simple API:** Igris provides a straightforward API for managing state in React applications, making it easy to integrate and use. Its intuitive API allows developers to quickly set up and manage state without a steep learning curve.
- **Type-safe:** Ensures that your application state is managed in a type-safe manner, reducing the risk of runtime errors. By leveraging TypeScript, Igris ensures that your state management is reliable and less prone to errors, leading to a more robust codebase and easier maintenance.
- **Synchronous & Asynchronous Storage:** Choose between synchronous and asynchronous storage options based on your application's requirements. Whether you need immediate state updates or handling state in more complex scenarios, Igris has you covered.
- **Efficient Data Persistence:** Igris offers efficient data persistence, ensuring that your application state is reliably stored across sessions. This is crucial for applications that need to maintain data across sessions, providing seamless saving and restoring of your application state.
- **Customizable Configuration:** Customize storage and persistence options to suit your application's needs. Igris offers a high level of customization, making it suitable for a wide range of applications, from simple to complex.
- **Seamless Integration:** Igris seamlessly integrates with various storage mechanisms, providing flexibility and compatibility. Integrating Igris into your existing React or React Native project is straightforward, allowing easy adoption without significant changes to your current setup.
- **Simple API:** Straightforward and intuitive for quick setup and easy state management.
- **Type-safe:** Leverages TypeScript to ensure reliable and error-resistant state management.
- **Synchronous & Asynchronous Storage:** Flexible options to suit various application requirements.
- **Efficient Data Persistence:** Reliable state storage across sessions for seamless user experiences.
- **Customizable Configuration:** Adaptable storage and persistence options for diverse application needs.
- **Seamless Integration:** Easy to adopt in existing React and React Native projects.
## Installation
You can install Igris via npm or yarn:
Install Igris using npm:
```
```bash
npm install igris
```
or
Or using yarn:
```
```bash
yarn add igris

@@ -30,2 +34,4 @@ ```

### Store Example
```tsx

@@ -35,4 +41,2 @@ import React from 'react';

// **Store Example**
// Create a new instance of the store with initial state and actions

@@ -42,12 +46,8 @@ export const useCount = createStore(

({ set, get }) => ({
increment: () => {
set({ count: get().count + 1 });
},
decrement: () => {
set({ count: get().count - 1 });
},
increment: () => set({ count: get().count + 1 }),
decrement: () => set({ count: get().count - 1 }),
})
);
// Without selector
// Component using the entire store
const CounterComponent = () => {

@@ -65,17 +65,14 @@ const { count, decrement, increment } = useCount();

// With selector to get state
// Component using a selector for state
const CountDisplayComponent = () => {
const count = useCount((state) => state.count);
return (
<div>
<p>Count: {count}</p>
</div>
);
return <p>Count: {count}</p>;
};
// With selector to get actions
// Component using a selector for actions
const CountActionsComponent = () => {
const increment = useCount((state) => state.increment);
const decrement = useCount((state) => state.decrement);
const { increment, decrement } = useCount((state) => ({
increment: state.increment,
decrement: state.decrement,
}));

@@ -89,5 +86,7 @@ return (

};
```
// **State Example**
### State Example
```tsx
export const useDarkTheme = createState(true);

@@ -108,14 +107,39 @@

## Documentation
For detailed documentation and usage examples, please visit the Igris GitHub repository.
## API Reference
### `createStore(initialState, actions)`
Creates a new store with the given initial state and actions.
- `initialState`: An object representing the initial state of the store.
- `actions`: A function that receives `set` and `get` methods and returns an object of actions.
### `createState(initialValue)`
Creates a new state hook with the given initial value.
- `initialValue`: The initial value of the state.
## Advanced Usage
For comprehensive usage examples and detailed API documentation, please visit our [official documentation site](https://igris-doc.web.app/).
## Contributing
We welcome contributions from the community! If you encounter any issues or have suggestions for improvement, please feel free to open an issue or submit a pull request on the <a href = "https://github.com/alok-shete/igris" target="_blank"> Igris GitHub repository.<a>
## Donate
We welcome contributions from the community! If you encounter any issues or have suggestions for improvement, please feel free to [open an issue](https://github.com/alok-shete/igris/issues) or submit a pull request on the [Igris GitHub repository](https://github.com/alok-shete/igris).
Please consider donating if you think HTTPtestify is helpful to you or that my work is valuable. I am happy if you can help me <a href = "https://www.buymeacoffee.com/shetealok" target="_blank">buy a cup of coffee. ❤️
## Support
If you find Igris helpful, consider supporting its development:
[!["Buy Me A Coffee"](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-ffdd00?style=for-the-badge&logo=buy-me-a-coffee&logoColor=black)](https://www.buymeacoffee.com/shetealok)
Your support helps maintain and improve Igris for the entire community.
## License
This project is licensed under the <a href = "https://github.com/alok-shete/igris/blob/main/LICENSE" target="_blank">MIT License</a>
This project is licensed under the [MIT License](https://github.com/alok-shete/igris/blob/main/LICENSE).
---
Made with ❤️ by [Alok Shete](https://alokshete.com)

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc