@mantine/store
Advanced tools
Comparing version 7.0.0-alpha.13 to 7.0.0-alpha.14
@@ -15,4 +15,7 @@ 'use strict'; | ||
}, | ||
updateState(value) { | ||
state = typeof value === "function" ? value(state) : value; | ||
}, | ||
setState(value) { | ||
state = value; | ||
this.updateState(value); | ||
listeners.forEach((listener) => listener(state)); | ||
@@ -19,0 +22,0 @@ }, |
@@ -11,4 +11,7 @@ import { useSyncExternalStore } from 'react'; | ||
}, | ||
updateState(value) { | ||
state = typeof value === "function" ? value(state) : value; | ||
}, | ||
setState(value) { | ||
state = value; | ||
this.updateState(value); | ||
listeners.forEach((listener) => listener(state)); | ||
@@ -15,0 +18,0 @@ }, |
export type MantineStoreSubscriber<Value> = (value: Value) => void; | ||
type SetStateCallback<Value> = (value: Value) => Value; | ||
export interface MantineStore<Value> { | ||
getState(): Value; | ||
setState(value: Value): void; | ||
setState(value: Value | SetStateCallback<Value>): void; | ||
updateState(value: Value | SetStateCallback<Value>): void; | ||
initialize(value: Value): void; | ||
@@ -9,3 +11,4 @@ subscribe(callback: MantineStoreSubscriber<Value>): () => void; | ||
export type MantineStoreValue<Store extends MantineStore<any>> = ReturnType<Store['getState']>; | ||
export declare function createStore<Value>(initialState: Value): MantineStore<Value>; | ||
export declare function createStore<Value extends Record<string, any>>(initialState: Value): MantineStore<Value>; | ||
export declare function useStore<Store extends MantineStore<any>>(store: Store): ReturnType<Store["getState"]>; | ||
export {}; |
{ | ||
"name": "@mantine/store", | ||
"version": "7.0.0-alpha.13", | ||
"version": "7.0.0-alpha.14", | ||
"types": "./lib/index.d.ts", | ||
@@ -32,3 +32,3 @@ "exports": { | ||
"peerDependencies": { | ||
"react": ">=16.8.0" | ||
"react": ">=18.0.0" | ||
}, | ||
@@ -35,0 +35,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9833
102