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

cra-template-demplate

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cra-template-demplate - npm Package Compare versions

Comparing version 0.2.5 to 0.2.6

template/src/utils/persist2Middleware.ts

2

package.json
{
"name": "cra-template-demplate",
"version": "0.2.5",
"version": "0.2.6",
"keywords": [

@@ -5,0 +5,0 @@ "react",

@@ -7,7 +7,6 @@ import {Middleware} from '@/utils/zustand';

get,
store,
$$storeMutations
store
) => config(args => {
set(args);
console.log('TODO: Add custom middleware logic here');
}, get, store, $$storeMutations);
}, get, store);

@@ -1,3 +0,4 @@

import {applyMiddleware, logMiddleware, StoreInterface} from '@/utils/zustand';
import {syncMiddlewareCreator} from '@/utils/syncMiddleware';
import {applyMiddleware, logMiddleware, Middleware} from '@/utils/zustand';
import {persistMiddlewareCreator} from '@/utils/persist2Middleware';
import {StateCreator} from 'zustand';

@@ -18,3 +19,3 @@ export enum Locale {

const store: StoreInterface<Store> = (set) => ({
const store: StateCreator<Store> = (set) => ({
locale: defaultLocale,

@@ -25,7 +26,7 @@ setLocale: (locale: Locale) => set(() => ({locale}))

export const useLocaleStore = applyMiddleware<Store>(store, [
syncMiddlewareCreator({
persistMiddlewareCreator({
name: 'locale',
syncDynamically: true
}),
}) as Middleware<Store>,
logMiddleware
]);

@@ -1,4 +0,5 @@

import {applyMiddleware, logMiddleware, StoreInterface} from '@/utils/zustand';
import {applyMiddleware, logMiddleware} from '@/utils/zustand';
import {sleep} from '@/utils';
import {testMiddleware} from '@/middleware/test';
import {StateCreator} from 'zustand';

@@ -15,3 +16,3 @@ export interface Test {

const store: StoreInterface<Test> = (set, get) => ({
const store: StateCreator<Test> = (set, get) => ({
a: 0,

@@ -18,0 +19,0 @@ b: 0,

import create, {GetState, SetState, StateCreator, StoreApi} from 'zustand';
import {log} from '@/utils/index';
export type StoreInterface<T extends {}> = (
set: SetState<T>,
get: GetState<T>,
api: StoreApi<T>,
$$storeMutations: any
) => T;
export type Middleware<T extends {}> = (
config: StateCreator<T>,
) => StoreInterface<T>;
) => StateCreator<T>;
export const applyMiddleware = <T extends {}>(s: StoreInterface<T>, middlewares: Middleware<T>[]) => create<T>(
export const applyMiddleware = <T extends {}>(s: StateCreator<T>, middlewares: Middleware<T>[]) => create<T>(
middlewares.reduce((a, m) => m(a), s)

@@ -22,4 +15,3 @@ );

get: GetState<T>,
store: StoreApi<T>,
$$storeMutations: any
store: StoreApi<T>
) => config(args => {

@@ -29,2 +21,2 @@ log(' applying', args);

log(' new state', get());
}, get, store, $$storeMutations);
}, get, store);
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