@ngneat/elf
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -10,2 +10,2 @@ export { Store, Reducer, StoreValue, StoreDef, ReducerContext, } from './lib/store'; | ||
export { StateOf, Query, OrArray } from './lib/types'; | ||
export { setProp } from './lib/mutations'; | ||
export { setProp, setProps } from './lib/mutations'; |
@@ -344,3 +344,28 @@ import { Subject, BehaviorSubject, Observable, pipe, asapScheduler } from 'rxjs'; | ||
} | ||
/** | ||
* | ||
* Update a root property of the state | ||
* | ||
* @example | ||
* | ||
* store.update(setProps({ count: 1, bar: 'baz'})) | ||
* | ||
* @example | ||
* | ||
* store.update(setProps(state => ({ | ||
* count: 1, | ||
* nested: { | ||
* ...state.nested, | ||
* foo: 'bar' | ||
* } | ||
* }))) | ||
* | ||
*/ | ||
export { Store, asap, capitalize, coerceArray, createState, distinctUntilArrayItemChanged, filterNil, getRegistry, getStore, getStoresSnapshot, head, isFunction, isObject, isString, isUndefined, propsArrayFactory, propsFactory, registry$, select, setProp, withProps }; | ||
function setProps(props) { | ||
return function (state) { | ||
return Object.assign({}, state, isFunction(props) ? props(state) : props); | ||
}; | ||
} | ||
export { Store, asap, capitalize, coerceArray, createState, distinctUntilArrayItemChanged, filterNil, getRegistry, getStore, getStoresSnapshot, head, isFunction, isObject, isString, isUndefined, propsArrayFactory, propsFactory, registry$, select, setProp, setProps, withProps }; |
@@ -434,3 +434,28 @@ (function (global, factory) { | ||
} | ||
/** | ||
* | ||
* Update a root property of the state | ||
* | ||
* @example | ||
* | ||
* store.update(setProps({ count: 1, bar: 'baz'})) | ||
* | ||
* @example | ||
* | ||
* store.update(setProps(state => ({ | ||
* count: 1, | ||
* nested: { | ||
* ...state.nested, | ||
* foo: 'bar' | ||
* } | ||
* }))) | ||
* | ||
*/ | ||
function setProps(props) { | ||
return function (state) { | ||
return __assign(__assign({}, state), isFunction(props) ? props(state) : props); | ||
}; | ||
} | ||
exports.Store = Store; | ||
@@ -456,2 +481,3 @@ exports.asap = asap; | ||
exports.setProp = setProp; | ||
exports.setProps = setProps; | ||
exports.withProps = withProps; | ||
@@ -458,0 +484,0 @@ |
@@ -16,1 +16,21 @@ import { Reducer } from './store'; | ||
export declare function setProp<S extends Record<string, any>, K extends keyof S>(key: K, value: S[K] | ((current: S[K]) => S[K])): Reducer<S>; | ||
/** | ||
* | ||
* Update a root property of the state | ||
* | ||
* @example | ||
* | ||
* store.update(setProps({ count: 1, bar: 'baz'})) | ||
* | ||
* @example | ||
* | ||
* store.update(setProps(state => ({ | ||
* count: 1, | ||
* nested: { | ||
* ...state.nested, | ||
* foo: 'bar' | ||
* } | ||
* }))) | ||
* | ||
*/ | ||
export declare function setProps<S extends Record<string, any>, V extends Partial<S>>(props: V | ((state: S) => V)): Reducer<S>; |
{ | ||
"name": "@ngneat/elf", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "A reactive state management for JS applications", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
34741
877
0