Comparing version 1.11.3 to 1.12.0
@@ -0,1 +1,5 @@ | ||
## 1.12.0 | ||
Some TypeScript type updates - hopefully fixing some `strict: true` issues people were having. | ||
### 1.11.3 | ||
@@ -2,0 +6,0 @@ |
@@ -8,3 +8,2 @@ import { IPullstateAllStores } from "./PullstateCore"; | ||
export declare class PullstateAsyncError extends Error { | ||
message: string; | ||
tags: string[]; | ||
@@ -11,0 +10,0 @@ constructor(message: string, tags: string[]); |
@@ -100,3 +100,3 @@ import isEqual from'fast-deep-equal/es6';import React,{useRef,useState,useEffect,useContext,useMemo}from'react';import produce$1,{produceWithPatches,produce,applyPatches}from'immer';function useStoreState(store, getSubState, deps) { | ||
if (store._optListenerCount > 0) { | ||
const [nextState, patches, inversePatches] = produceWithPatches(currentState, s => reaction(nextWatchState, s, currentState, lastWatchState)); | ||
const [nextState, patches, inversePatches] = produceWithPatches(currentState, (s) => reaction(nextWatchState, s, currentState, lastWatchState)); | ||
store._updateStateWithoutReaction(nextState); | ||
@@ -111,3 +111,3 @@ lastWatchState = nextWatchState; | ||
if (store._patchListeners.length > 0) { | ||
const [nextState, patches, inversePatches] = produceWithPatches(currentState, s => reaction(nextWatchState, s, currentState, lastWatchState)); | ||
const [nextState, patches, inversePatches] = produceWithPatches(currentState, (s) => reaction(nextWatchState, s, currentState, lastWatchState)); | ||
if (patches.length > 0) { | ||
@@ -119,3 +119,3 @@ store._patchListeners.forEach(listener => listener(patches, inversePatches)); | ||
else { | ||
store._updateStateWithoutReaction(produce(currentState, s => reaction(nextWatchState, s, currentState, lastWatchState))); | ||
store._updateStateWithoutReaction(produce(currentState, (s) => reaction(nextWatchState, s, currentState, lastWatchState))); | ||
} | ||
@@ -246,4 +246,3 @@ lastWatchState = nextWatchState; | ||
} | ||
createPathReaction(path, reaction) { | ||
} | ||
createPathReaction(path, reaction) { } | ||
getRawState() { | ||
@@ -319,5 +318,5 @@ if (this.batchState !== undefined) { | ||
return func | ||
? produceWithPatches(currentState, s => updater(s, currentState)) | ||
? produceWithPatches(currentState, (s) => updater(s, currentState)) | ||
: updater.reduce(([nextState, patches, inversePatches], currentValue) => { | ||
const resp = produceWithPatches(nextState, s => currentValue(s, nextState)); | ||
const resp = produceWithPatches(nextState, (s) => currentValue(s, nextState)); | ||
patches.push(...resp[1]); | ||
@@ -354,6 +353,6 @@ inversePatches.push(...resp[2]); | ||
else { | ||
nextState = produce(currentState, s => func | ||
nextState = produce(currentState, (s) => func | ||
? updater(s, currentState) | ||
: updater.reduce((previousValue, currentUpdater) => { | ||
return produce(previousValue, s => currentUpdater(s, previousValue)); | ||
return produce(previousValue, (s) => currentUpdater(s, previousValue)); | ||
}, currentState)); | ||
@@ -849,3 +848,3 @@ } | ||
const newResult = { | ||
payload: produce$1(currentCached, s => updater(s, currentCached)), | ||
payload: produce$1(currentCached, (s) => updater(s, currentCached)), | ||
error: false, | ||
@@ -852,0 +851,0 @@ message: cache.results[key][2].message, |
@@ -100,3 +100,3 @@ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});function _interopDefault(e){return(e&&(typeof e==='object')&&'default'in e)?e['default']:e}var isEqual=_interopDefault(require('fast-deep-equal/es6')),React=require('react'),React__default=_interopDefault(React),produce=require('immer'),produce__default=_interopDefault(produce);function useStoreState(store, getSubState, deps) { | ||
if (store._optListenerCount > 0) { | ||
const [nextState, patches, inversePatches] = produce.produceWithPatches(currentState, s => reaction(nextWatchState, s, currentState, lastWatchState)); | ||
const [nextState, patches, inversePatches] = produce.produceWithPatches(currentState, (s) => reaction(nextWatchState, s, currentState, lastWatchState)); | ||
store._updateStateWithoutReaction(nextState); | ||
@@ -111,3 +111,3 @@ lastWatchState = nextWatchState; | ||
if (store._patchListeners.length > 0) { | ||
const [nextState, patches, inversePatches] = produce.produceWithPatches(currentState, s => reaction(nextWatchState, s, currentState, lastWatchState)); | ||
const [nextState, patches, inversePatches] = produce.produceWithPatches(currentState, (s) => reaction(nextWatchState, s, currentState, lastWatchState)); | ||
if (patches.length > 0) { | ||
@@ -119,3 +119,3 @@ store._patchListeners.forEach(listener => listener(patches, inversePatches)); | ||
else { | ||
store._updateStateWithoutReaction(produce.produce(currentState, s => reaction(nextWatchState, s, currentState, lastWatchState))); | ||
store._updateStateWithoutReaction(produce.produce(currentState, (s) => reaction(nextWatchState, s, currentState, lastWatchState))); | ||
} | ||
@@ -246,4 +246,3 @@ lastWatchState = nextWatchState; | ||
} | ||
createPathReaction(path, reaction) { | ||
} | ||
createPathReaction(path, reaction) { } | ||
getRawState() { | ||
@@ -319,5 +318,5 @@ if (this.batchState !== undefined) { | ||
return func | ||
? produce.produceWithPatches(currentState, s => updater(s, currentState)) | ||
? produce.produceWithPatches(currentState, (s) => updater(s, currentState)) | ||
: updater.reduce(([nextState, patches, inversePatches], currentValue) => { | ||
const resp = produce.produceWithPatches(nextState, s => currentValue(s, nextState)); | ||
const resp = produce.produceWithPatches(nextState, (s) => currentValue(s, nextState)); | ||
patches.push(...resp[1]); | ||
@@ -354,6 +353,6 @@ inversePatches.push(...resp[2]); | ||
else { | ||
nextState = produce.produce(currentState, s => func | ||
nextState = produce.produce(currentState, (s) => func | ||
? updater(s, currentState) | ||
: updater.reduce((previousValue, currentUpdater) => { | ||
return produce.produce(previousValue, s => currentUpdater(s, previousValue)); | ||
return produce.produce(previousValue, (s) => currentUpdater(s, previousValue)); | ||
}, currentState)); | ||
@@ -847,3 +846,3 @@ } | ||
const newResult = { | ||
payload: produce__default(currentCached, s => updater(s, currentCached)), | ||
payload: produce__default(currentCached, (s) => updater(s, currentCached)), | ||
error: false, | ||
@@ -850,0 +849,0 @@ message: cache.results[key][2].message, |
@@ -17,3 +17,3 @@ import React from "react"; | ||
}; | ||
export declare type TMultiStoreAction<P extends PullstateSingleton, S extends IPullstateAllStores = P extends PullstateSingleton<infer ST> ? ST : any> = (update: TMultiStoreUpdateMap<S>) => void; | ||
export declare type TMultiStoreAction<P extends PullstateSingleton<S>, S extends IPullstateAllStores = P extends PullstateSingleton<infer ST> ? ST : any> = (update: TMultiStoreUpdateMap<S>) => void; | ||
export declare class PullstateSingleton<S extends IPullstateAllStores = IPullstateAllStores> { | ||
@@ -20,0 +20,0 @@ constructor(allStores: S); |
{ | ||
"name": "pullstate", | ||
"version": "1.11.3", | ||
"version": "1.12.0", | ||
"description": "Simple state stores using immer and React hooks", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
139509
2670