@rimbu/actor
Advanced tools
Comparing version 0.9.5 to 0.10.0
@@ -99,4 +99,5 @@ "use strict"; | ||
var newPureState = (0, common_1.Update)(oldPureState, updatePureState); | ||
if (Object.is(newPureState, oldPureState)) | ||
if (Object.is(newPureState, oldPureState)) { | ||
return; | ||
} | ||
this.pureState = newPureState; | ||
@@ -118,9 +119,5 @@ if (!((_a = this.options) === null || _a === void 0 ? void 0 : _a.derive)) { | ||
}; | ||
Impl.prototype.patchState = function () { | ||
var patches = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
patches[_i] = arguments[_i]; | ||
} | ||
Impl.prototype.patchState = function (patchItem) { | ||
var pureState = this.pureState; | ||
var newState = deep_1.patch.apply(void 0, tslib_1.__spreadArray([pureState], tslib_1.__read(patches), false)); | ||
var newState = deep_1.Deep.patch(pureState, patchItem); | ||
this.setState(newState); | ||
@@ -184,5 +181,5 @@ }; | ||
return this.map(function (newParentState) { | ||
return deep_1.Path.get(newParentState, pathInState); | ||
return deep_1.Deep.getAt(newParentState, pathInState); | ||
}, function (newChildState) { | ||
return deep_1.Path.update(_this.pureState, pathInState, newChildState); | ||
return deep_1.Deep.patchAt(_this.pureState, pathInState, newChildState); | ||
}, options); | ||
@@ -192,3 +189,3 @@ }; | ||
return this.mapReadonly(function (newParentState) { | ||
return deep_1.Path.get(newParentState, pathInState); | ||
return deep_1.Deep.getAt(newParentState, pathInState); | ||
}, options); | ||
@@ -195,0 +192,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
import { patch, Path } from '@rimbu/deep'; | ||
import { Deep } from '@rimbu/deep'; | ||
import { Update } from '@rimbu/common'; | ||
@@ -63,4 +63,5 @@ class NotifierBase { | ||
const newPureState = Update(oldPureState, updatePureState); | ||
if (Object.is(newPureState, oldPureState)) | ||
if (Object.is(newPureState, oldPureState)) { | ||
return; | ||
} | ||
this.pureState = newPureState; | ||
@@ -82,5 +83,5 @@ if (!((_a = this.options) === null || _a === void 0 ? void 0 : _a.derive)) { | ||
} | ||
patchState(...patches) { | ||
patchState(patchItem) { | ||
const pureState = this.pureState; | ||
const newState = patch(pureState, ...patches); | ||
const newState = Deep.patch(pureState, patchItem); | ||
this.setState(newState); | ||
@@ -138,8 +139,8 @@ } | ||
select(pathInState, options) { | ||
return this.map((newParentState) => Path.get(newParentState, pathInState), (newChildState) => { | ||
return Path.update(this.pureState, pathInState, newChildState); | ||
return this.map((newParentState) => Deep.getAt(newParentState, pathInState), (newChildState) => { | ||
return Deep.patchAt(this.pureState, pathInState, newChildState); | ||
}, options); | ||
} | ||
selectReadonly(pathInState, options) { | ||
return this.mapReadonly((newParentState) => Path.get(newParentState, pathInState), options); | ||
return this.mapReadonly((newParentState) => Deep.getAt(newParentState, pathInState), options); | ||
} | ||
@@ -146,0 +147,0 @@ combineReadonly(other, mapTo, options) { |
@@ -1,2 +0,2 @@ | ||
import { type Protected, Patch, Path } from '@rimbu/deep'; | ||
import { type Protected, type Patch, type Path } from '@rimbu/deep'; | ||
import { Update } from '@rimbu/common'; | ||
@@ -127,3 +127,3 @@ /** | ||
*/ | ||
selectReadonly: <P extends Path<T & D>, DR = unknown>(pathInState: P, options?: { | ||
selectReadonly: <P extends Path.Get<T & D>, DR = unknown>(pathInState: P, options?: { | ||
derive?: (newState: Protected<Path.Result<T & D, P>>, oldState: Protected<Path.Result<T & D, P>>, oldDerived?: Protected<DR>) => DR; | ||
@@ -155,3 +155,3 @@ onFirstSubscription?: () => Obs.UnsubscribeFn; | ||
*/ | ||
select: <P extends Path<T>, DR = unknown>(pathInState: P, options?: { | ||
select: <P extends Path.Set<T>, DR = unknown>(pathInState: P, options?: { | ||
derive?: (newState: Protected<Path.Result<T, P>>, oldState: Protected<Path.Result<T, P>>, oldDerived?: Protected<DR>) => DR; | ||
@@ -331,3 +331,3 @@ onFirstSubscription?: () => Obs.UnsubscribeFn; | ||
*/ | ||
selectReadonly: <P extends Path<T>, DR = unknown>(pathInState: P, options?: { | ||
selectReadonly: <P extends Path.Get<T>, DR = unknown>(pathInState: P, options?: { | ||
derive?: (newState: Protected<Path.Result<T, P>>, oldState: Protected<Path.Result<T, P>>, oldDerived?: Protected<DR>) => DR; | ||
@@ -334,0 +334,0 @@ onFirstSubscription?: () => Obs.UnsubscribeFn; |
{ | ||
"name": "@rimbu/actor", | ||
"version": "0.9.5", | ||
"version": "0.10.0", | ||
"description": "State management tools to create stateful logic that can be easily integrated in any framework", | ||
@@ -58,4 +58,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@rimbu/base": "^0.9.5", | ||
"@rimbu/deep": "^0.11.3", | ||
"@rimbu/base": "^0.10.0", | ||
"@rimbu/deep": "^0.12.0", | ||
"tslib": "^2.4.0" | ||
@@ -70,3 +70,3 @@ }, | ||
}, | ||
"gitHead": "c4009664c4e15f367e963d198cacd7c5fc182a4d" | ||
"gitHead": "22ae1cadeb885e7fd30a23bd05c001cda3141e86" | ||
} |
@@ -1,3 +0,2 @@ | ||
import { type Protected, patch, Patch, Path } from '@rimbu/deep'; | ||
import type { PlainObj } from '@rimbu/base'; | ||
import { type Protected, type Patch, type Path, Deep } from '@rimbu/deep'; | ||
import { Update } from '@rimbu/common'; | ||
@@ -92,3 +91,5 @@ | ||
if (Object.is(newPureState, oldPureState)) return; | ||
if (Object.is(newPureState, oldPureState)) { | ||
return; | ||
} | ||
@@ -130,6 +131,6 @@ this.pureState = newPureState; | ||
patchState(...patches: Patch<T>[]): void { | ||
patchState(patchItem: Patch<T>): void { | ||
const pureState = this.pureState; | ||
const newState = patch(pureState as any, ...patches); | ||
const newState = Deep.patch(pureState, patchItem); | ||
@@ -217,3 +218,3 @@ this.setState(newState); | ||
select<P extends Path<T>, DR = unknown>( | ||
select<P extends Path.Set<T>, DR = unknown>( | ||
pathInState: P, | ||
@@ -231,6 +232,6 @@ options?: { | ||
(newParentState: Protected<T & D>) => | ||
Path.get(newParentState as T & PlainObj<any>, pathInState), | ||
Deep.getAt(newParentState as T, pathInState as any) as any, | ||
(newChildState: Protected<Path.Result<T, P>>): T => { | ||
return Path.update( | ||
this.pureState as T & PlainObj<any>, | ||
return Deep.patchAt( | ||
this.pureState as T, | ||
pathInState, | ||
@@ -244,3 +245,3 @@ newChildState as any | ||
selectReadonly<P extends Path<T & D>, DR>( | ||
selectReadonly<P extends Path.Get<T & D>, DR>( | ||
pathInState: P, | ||
@@ -258,3 +259,3 @@ options?: { | ||
(newParentState: Protected<T & D>) => | ||
Path.get(newParentState as T & D & PlainObj<any>, pathInState), | ||
Deep.getAt(newParentState as T & D, pathInState), | ||
options | ||
@@ -491,3 +492,3 @@ ); | ||
*/ | ||
selectReadonly: <P extends Path<T & D>, DR = unknown>( | ||
selectReadonly: <P extends Path.Get<T & D>, DR = unknown>( | ||
pathInState: P, | ||
@@ -526,3 +527,3 @@ options?: { | ||
*/ | ||
select: <P extends Path<T>, DR = unknown>( | ||
select: <P extends Path.Set<T>, DR = unknown>( | ||
pathInState: P, | ||
@@ -736,3 +737,3 @@ options?: { | ||
*/ | ||
selectReadonly: <P extends Path<T>, DR = unknown>( | ||
selectReadonly: <P extends Path.Get<T>, DR = unknown>( | ||
pathInState: P, | ||
@@ -739,0 +740,0 @@ options?: { |
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
115347
2289
+ Added@rimbu/base@0.10.1(transitive)
+ Added@rimbu/common@0.11.0(transitive)
+ Added@rimbu/deep@0.12.1(transitive)
- Removed@rimbu/base@0.9.5(transitive)
- Removed@rimbu/deep@0.11.3(transitive)
Updated@rimbu/base@^0.10.0
Updated@rimbu/deep@^0.12.0