New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pullstate

Package Overview
Dependencies
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pullstate - npm Package Compare versions

Comparing version

to
1.13.0

6

Changelog.md

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

## 1.13.0
Added in `createAsyncActionDirect()` - which allows you to simply directly wrap promises instead of using `successResult()` or `errorResult()` methods implicitly. Useful for scenarios that don't require such verbosity. It will directly return a `successResult()` - or otherwise, if an error is thrown, an `errorResult()`.
Allow `use()` of an async action to be executed on the same arguments later on in the component, with the returned method `execute()`.
## 1.12.0

@@ -2,0 +8,0 @@

1

dist/async-types.d.ts

@@ -163,2 +163,3 @@ import { IPullstateAllStores } from "./PullstateCore";

raw: TPullstateAsyncWatchResponse<R, T>;
execute: (runOptions?: IAsyncActionRunOptions) => TPullstateAsyncRunResponse<R, T>;
}

@@ -165,0 +166,0 @@ export interface IBaseObjSuccessResponse<R, T extends string> extends IBaseObjResponse<R, T> {

@@ -11,2 +11,3 @@ import { IPullstateAllStores } from "./PullstateCore";

}
export declare function createAsyncActionDirect<A = any, R = any, S extends IPullstateAllStores = IPullstateAllStores>(action: (args: A) => Promise<R>, options?: ICreateAsyncActionOptions<A, R, string, S>): IOCreateAsyncActionOutput<A, R>;
export declare function createAsyncAction<A = any, R = any, T extends string = string, S extends IPullstateAllStores = IPullstateAllStores>(action: TPullstateAsyncAction<A, R, T, S>, { forceContext, shortCircuitHook, cacheBreakHook, postActionHook, subsetKey, }?: ICreateAsyncActionOptions<A, R, T, S>): IOCreateAsyncActionOutput<A, R, T>;

4

dist/index.d.ts

@@ -6,3 +6,3 @@ import { useStoreState } from "./useStoreState";

import { createPullstateCore, IPullstateAllStores, IPullstateInstanceConsumable, PullstateContext, PullstateProvider, TMultiStoreAction, useInstance, useStores } from "./PullstateCore";
import { createAsyncAction, errorResult, successResult } from "./async";
import { createAsyncAction, errorResult, successResult, createAsyncActionDirect } from "./async";
import { EAsyncActionInjectType, InjectAsyncAction, TInjectAsyncActionProps } from "./InjectAsyncAction";

@@ -12,2 +12,2 @@ import { InjectStoreStateOpt } from "./InjectStoreStateOpt";

export * from "./async-types";
export { useStoreState, useStoreStateOpt, update, Store, InjectStoreState, InjectStoreStateOpt, PullstateProvider, useStores, useInstance, createPullstateCore, createAsyncAction, successResult, errorResult, IPullstateInstanceConsumable, IPullstateAllStores, InjectAsyncAction, EAsyncActionInjectType, TInjectAsyncActionProps, TUpdateFunction, TStoreAction, TMultiStoreAction, PullstateContext, TUseResponse, };
export { useStoreState, useStoreStateOpt, update, Store, InjectStoreState, InjectStoreStateOpt, PullstateProvider, useStores, useInstance, createPullstateCore, createAsyncAction, createAsyncActionDirect, successResult, errorResult, IPullstateInstanceConsumable, IPullstateAllStores, InjectAsyncAction, EAsyncActionInjectType, TInjectAsyncActionProps, TUpdateFunction, TStoreAction, TMultiStoreAction, PullstateContext, TUseResponse, };

@@ -286,2 +286,5 @@ 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) {

}
replace(newState) {
this._updateState(newState);
}
applyPatches(patches) {

@@ -471,2 +474,7 @@ applyPatchesToStore(this, patches);

}
function createAsyncActionDirect(action, options = {}) {
return createAsyncAction(async (args) => {
return successResult(await action(args));
}, options);
}
function createAsyncAction(action, { forceContext = false, shortCircuitHook, cacheBreakHook, postActionHook, subsetKey, } = {}) {

@@ -961,2 +969,3 @@ const ordinal = asyncCreationOrdinal++;

raw,
execute: (runOptions => run(args, runOptions)),
};

@@ -1054,2 +1063,5 @@ };

}
createAsyncActionDirect(action, options = {}) {
return createAsyncActionDirect(action, options);
}
createAsyncAction(action, options = {}) {

@@ -1140,2 +1152,2 @@ return createAsyncAction(action, options);

return children(state);
}export{EAsyncActionInjectType,EAsyncEndTags,EPostActionContext,InjectAsyncAction,InjectStoreState,InjectStoreStateOpt,PullstateContext,PullstateProvider,Store,createAsyncAction,createPullstateCore,errorResult,successResult,update,useInstance,useStoreState,useStoreStateOpt,useStores};
}export{EAsyncActionInjectType,EAsyncEndTags,EPostActionContext,InjectAsyncAction,InjectStoreState,InjectStoreStateOpt,PullstateContext,PullstateProvider,Store,createAsyncAction,createAsyncActionDirect,createPullstateCore,errorResult,successResult,update,useInstance,useStoreState,useStoreStateOpt,useStores};

@@ -286,2 +286,5 @@ '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) {

}
replace(newState) {
this._updateState(newState);
}
applyPatches(patches) {

@@ -469,2 +472,7 @@ applyPatchesToStore(this, patches);

}
function createAsyncActionDirect(action, options = {}) {
return createAsyncAction(async (args) => {
return successResult(await action(args));
}, options);
}
function createAsyncAction(action, { forceContext = false, shortCircuitHook, cacheBreakHook, postActionHook, subsetKey, } = {}) {

@@ -959,2 +967,3 @@ const ordinal = asyncCreationOrdinal++;

raw,
execute: (runOptions => run(args, runOptions)),
};

@@ -1052,2 +1061,5 @@ };

}
createAsyncActionDirect(action, options = {}) {
return createAsyncActionDirect(action, options);
}
createAsyncAction(action, options = {}) {

@@ -1137,2 +1149,2 @@ return createAsyncAction(action, options);

return children(state);
}exports.InjectAsyncAction=InjectAsyncAction;exports.InjectStoreState=InjectStoreState;exports.InjectStoreStateOpt=InjectStoreStateOpt;exports.PullstateContext=PullstateContext;exports.PullstateProvider=PullstateProvider;exports.Store=Store;exports.createAsyncAction=createAsyncAction;exports.createPullstateCore=createPullstateCore;exports.errorResult=errorResult;exports.successResult=successResult;exports.update=update;exports.useInstance=useInstance;exports.useStoreState=useStoreState;exports.useStoreStateOpt=useStoreStateOpt;exports.useStores=useStores;
}exports.InjectAsyncAction=InjectAsyncAction;exports.InjectStoreState=InjectStoreState;exports.InjectStoreStateOpt=InjectStoreStateOpt;exports.PullstateContext=PullstateContext;exports.PullstateProvider=PullstateProvider;exports.Store=Store;exports.createAsyncAction=createAsyncAction;exports.createAsyncActionDirect=createAsyncActionDirect;exports.createPullstateCore=createPullstateCore;exports.errorResult=errorResult;exports.successResult=successResult;exports.update=update;exports.useInstance=useInstance;exports.useStoreState=useStoreState;exports.useStoreStateOpt=useStoreStateOpt;exports.useStores=useStores;

@@ -30,2 +30,3 @@ import React from "react";

};
createAsyncActionDirect<A = any, R = any>(action: (args: A) => Promise<R>, options?: ICreateAsyncActionOptions<A, R, string, S>): IOCreateAsyncActionOutput<A, R>;
createAsyncAction<A = any, R = any, T extends string = string>(action: TPullstateAsyncAction<A, R, T, S>, options?: ICreateAsyncActionOptions<A, R, T, S>): IOCreateAsyncActionOutput<A, R, T>;

@@ -32,0 +33,0 @@ }

@@ -51,2 +51,3 @@ import { Patch, PatchListener } from "immer";

update(updater: TUpdateFunction<S> | TUpdateFunction<S>[], patchesCallback?: (patches: Patch[], inversePatches: Patch[]) => void): void;
replace(newState: S): void;
applyPatches(patches: Patch[]): void;

@@ -53,0 +54,0 @@ }

{
"name": "pullstate",
"version": "1.12.0",
"version": "1.13.0",
"description": "Simple state stores using immer and React hooks",

@@ -5,0 +5,0 @@ "main": "dist/index.js",