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

@ngneat/elf-state-history

Package Overview
Dependencies
Maintainers
3
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ngneat/elf-state-history - npm Package Compare versions

Comparing version 1.2.2 to 1.3.0

9

CHANGELOG.md

@@ -5,2 +5,11 @@ # Changelog

# [1.3.0](https://github.com/ngneat/elf/compare/state-history-1.2.2...state-history-1.3.0) (2022-09-30)
### Features
* **state-history:** expose methods for retrieving future and past ([#341](https://github.com/ngneat/elf/issues/341)) ([6dc1a9f](https://github.com/ngneat/elf/commit/6dc1a9f1b8067b87286df1db3270d5b063440d18))
## [1.2.2](https://github.com/ngneat/elf/compare/state-history-1.2.1...state-history-1.2.2) (2022-09-09)

@@ -7,0 +16,0 @@

@@ -36,2 +36,10 @@ import { isFunction, coerceArray, filterNil, isUndefined } from '@ngneat/elf';

getPast() {
return this.history.past;
}
getFuture() {
return this.history.future;
}
activate() {

@@ -252,2 +260,26 @@ this.subscription = this.store.pipe(filter(() => !(this.skipUpdate || this.paused))).subscribe(present => {

getEntitiesPast(options = {
showIfEmpty: false
}) {
const pastByIds = {};
this.entitiesHistory.forEach((history, id) => {
if (options.showIfEmpty || history.past.length) {
pastByIds[id] = history.past;
}
});
return pastByIds;
}
getEntitiesFuture(options = {
showIfEmpty: false
}) {
const futureByIds = {};
this.entitiesHistory.forEach((history, id) => {
if (options.showIfEmpty || history.future.length) {
futureByIds[id] = history.future;
}
});
return futureByIds;
}
undo(ids) {

@@ -254,0 +286,0 @@ const entities = [];

import { Store, OrArray, StoreValue } from '@ngneat/elf';
import { EntitiesState, getIdType, EntitiesRef, getEntityType, DefaultEntitiesRef } from '@ngneat/elf-entities';
export interface EntitiesTimelineOptions {
showIfEmpty: boolean;
}
export interface EntitiesStateHistoryOptions<T extends Store<any, StoreValue<any> & EntitiesState<E>>, E extends EntitiesRef, S extends StoreValue<T> = StoreValue<T>> {

@@ -27,2 +30,4 @@ maxAge: number;

hasFuture(id: getIdType<S, E>): boolean;
getEntitiesPast(options?: EntitiesTimelineOptions): Record<getIdType<EntitiesState<E>, E>, Array<getEntityType<EntitiesState<E>, E>>>;
getEntitiesFuture(options?: EntitiesTimelineOptions): Record<getIdType<EntitiesState<E>, E>, Array<getEntityType<EntitiesState<E>, E>>>;
undo(ids?: OrArray<getIdType<S, E>>): void;

@@ -29,0 +34,0 @@ redo(ids?: OrArray<getIdType<S, E>>): void;

2

lib/state-history.d.ts

@@ -26,2 +26,4 @@ import { Store, StoreValue } from '@ngneat/elf';

get hasFuture(): boolean;
getPast(): History<State>['past'];
getFuture(): History<State>['future'];
activate(): void;

@@ -28,0 +30,0 @@ undo(): void;

2

package.json
{
"name": "@ngneat/elf-state-history",
"version": "1.2.2",
"version": "1.3.0",
"description": "State history management for elf store",

@@ -5,0 +5,0 @@ "publishConfig": {

Sorry, the diff of this file is not supported yet

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