Socket
Socket
Sign inDemoInstall

@agile-ts/core

Package Overview
Dependencies
0
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.10 to 0.0.11

6

CHANGELOG.md
# Change Log
## 0.0.11
### Patch Changes
- 93ead02: Bug fixes and Selector directly mutates item now
## 0.0.10

@@ -4,0 +10,0 @@

6

dist/agile.d.ts

@@ -1,2 +0,2 @@

import { Runtime, Integration, State, Storage, Collection, CollectionConfig, DefaultItem, Computed, Event, CreateEventConfigInterface, DefaultEventPayload, Integrations, Observer, SubController, Storages, CreateStorageConfigInterface, RegisterConfigInterface, Logger, CreateLoggerConfigInterface, StateConfigInterface } from './internal';
import { Runtime, Integration, State, Storage, Collection, CollectionConfig, DefaultItem, Computed, Event, CreateEventConfigInterface, DefaultEventPayload, Integrations, Observer, SubController, Storages, CreateStorageConfigInterface, RegisterConfigInterface, Logger, CreateLoggerConfigInterface, StateConfigInterface, Group } from './internal';
export declare class Agile {

@@ -28,3 +28,3 @@ config: AgileConfigInterface;

*/
createState<ValueType>(initialValue: ValueType, config?: StateConfigInterface): State<ValueType>;
createState<ValueType = any>(initialValue: ValueType, config?: StateConfigInterface): State<ValueType>;
/**

@@ -43,3 +43,3 @@ * @public

*/
createComputed<ComputedValueType = any>(computeFunction: () => ComputedValueType, config?: StateConfigInterface, deps?: Array<Observer | State | Event>): Computed<ComputedValueType>;
createComputed<ComputedValueType = any>(computeFunction: () => ComputedValueType, config?: StateConfigInterface, deps?: Array<Observer | State | Event | Group>): Computed<ComputedValueType>;
/**

@@ -46,0 +46,0 @@ * @public

@@ -14,3 +14,3 @@ "use strict";

localStorage: true,
waitForMount: false,
waitForMount: true,
logConfig: {},

@@ -17,0 +17,0 @@ });

@@ -1,2 +0,2 @@

import { Agile, Item, Group, GroupKey, Selector, SelectorKey, StorageKey, GroupConfigInterface, CollectionPersistent, GroupAddConfig } from '../internal';
import { Agile, Item, Group, GroupKey, Selector, SelectorKey, StorageKey, GroupConfigInterface, CollectionPersistent, GroupAddConfig, SideEffectConfigInterface, SelectorConfigInterface } from '../internal';
export declare class Collection<DataType = DefaultItem> {

@@ -19,2 +19,3 @@ agileInstance: () => Agile;

};
isInstantiated: boolean;
/**

@@ -56,5 +57,3 @@ * @public

*/
Selector(initialKey: ItemKey, config?: {
key?: SelectorKey;
}): Selector<DataType>;
Selector(initialKey: ItemKey, config?: SelectorConfigInterface): Selector<DataType>;
/**

@@ -185,2 +184,14 @@ * @internal

* @public
* Get all Items of Collection
* @param config - Config
*/
getAllItems(config?: HasConfigInterface): Array<Item<DataType>>;
/**
* @public
* Get all Values of Items in a Collection
* @param config - Config
*/
getAllItemValues(config?: HasConfigInterface): Array<DataType>;
/**
* @public
* Stores Collection Value into Agile Storage permanently

@@ -300,3 +311,3 @@ * @param config - Config

primaryKey?: string;
defaultGroupKey?: ItemKey;
defaultGroupKey?: GroupKey;
initialData?: Array<DataType>;

@@ -348,3 +359,3 @@ }

force?: boolean;
sideEffects?: boolean;
sideEffects?: SideEffectConfigInterface;
}

@@ -351,0 +362,0 @@ /**

@@ -18,2 +18,3 @@ "use strict";

this.selectors = {};
this.isInstantiated = false;
this.agileInstance = () => agileInstance;

@@ -43,2 +44,3 @@ // Set temp Config for creating proper Placeholder Items (of Selector)

this.collect(_config.initialData);
this.isInstantiated = true;
}

@@ -87,2 +89,9 @@ /**

Group(initialItems, config) {
if (this.isInstantiated) {
const key = (config === null || config === void 0 ? void 0 : config.key) || internal_1.generateId();
internal_1.Agile.logger.warn("After the instantiation we recommend using 'MY_COLLECTION.createGroup' instead of 'MY_COLLECTION.Group'");
if (!(config === null || config === void 0 ? void 0 : config.key))
internal_1.Agile.logger.warn(`Failed to find key for creation of Group. Group with random key '${key}' got created!`);
return this.createGroup(key, initialItems);
}
return new internal_1.Group(this, initialItems, config);

@@ -100,2 +109,9 @@ }

Selector(initialKey, config) {
if (this.isInstantiated) {
const key = (config === null || config === void 0 ? void 0 : config.key) || internal_1.generateId();
internal_1.Agile.logger.warn("After the instantiation we recommend using 'MY_COLLECTION.createSelector' instead of 'MY_COLLECTION.Selector'");
if (!(config === null || config === void 0 ? void 0 : config.key))
internal_1.Agile.logger.warn(`Failed to find key for creation of Selector. Selector with random key '${key}' got created!`);
return this.createSelector(key, initialKey);
}
return new internal_1.Selector(this, initialKey, config);

@@ -265,2 +281,5 @@ }

let group = this.getGroup(groupKey, { notExisting: true });
if (!this.isInstantiated) {
internal_1.Agile.logger.warn("We recommend to use 'MY_COLLECTION.Group' instead of 'MY_COLLECTION.createGroup' in the Collection config!");
}
// Check if Group already exists

@@ -361,2 +380,5 @@ if (group) {

let selector = this.getSelector(selectorKey, { notExisting: true });
if (!this.isInstantiated) {
internal_1.Agile.logger.warn("We recommend to use 'MY_COLLECTION.Selector' instead of 'MY_COLLECTION.createSelector' in the Collection config!");
}
// Check if Selector already exists

@@ -518,2 +540,36 @@ if (selector) {

}
//=========================================================================================================
// Get All Items
//=========================================================================================================
/**
* @public
* Get all Items of Collection
* @param config - Config
*/
getAllItems(config = {}) {
config = internal_1.defineConfig(config, {
notExisting: false,
});
// Get Items
const items = [];
for (const key in this.data) {
const item = this.data[key];
if ((!config.notExisting && item.exists) || config.notExisting) {
items.push(item);
}
}
return items;
}
//=========================================================================================================
// Get All Item Values
//=========================================================================================================
/**
* @public
* Get all Values of Items in a Collection
* @param config - Config
*/
getAllItemValues(config = {}) {
const items = this.getAllItems(config);
return items.map((item) => item.value);
}
persist(keyOrConfig = {}, config = {}) {

@@ -840,3 +896,6 @@ let _config;

background: false,
sideEffects: true,
sideEffects: {
enabled: true,
exclude: [],
},
});

@@ -843,0 +902,0 @@ // Rebuild Groups that include ItemKey

@@ -35,3 +35,6 @@ "use strict";

config = internal_1.defineConfig(config, {
sideEffects: true,
sideEffects: {
enabled: true,
exclude: [],
},
background: false,

@@ -67,3 +70,3 @@ force: false,

addRebuildGroupThatIncludeItemKeySideEffect(itemKey) {
this.addSideEffect(Item.updateGroupSideEffectKey, (config) => this.collection().rebuildGroupsThatIncludeItemKey(itemKey, config), { weight: 100 });
this.addSideEffect(Item.updateGroupSideEffectKey, (instance, config) => instance.collection().rebuildGroupsThatIncludeItemKey(itemKey, config), { weight: 100 });
}

@@ -70,0 +73,0 @@ }

@@ -5,2 +5,3 @@ import { Collection, DefaultItem, Item, ItemKey, State, StateRuntimeJobConfigInterface } from '../internal';

static rebuildSelectorSideEffectKey: string;
static rebuildItemSideEffectKey: string;
collection: () => Collection<DataType>;

@@ -7,0 +8,0 @@ item: Item<DataType> | undefined;

@@ -57,3 +57,6 @@ "use strict";

background: false,
sideEffects: true,
sideEffects: {
enabled: true,
exclude: [],
},
force: false,

@@ -73,3 +76,14 @@ overwrite: (oldItem === null || oldItem === void 0 ? void 0 : oldItem.isPlaceholder) || false,

// Add SideEffect to newItem, that rebuild this Selector depending on the current Item Value
newItem.addSideEffect(Selector.rebuildSelectorSideEffectKey, (config) => this.rebuildSelector(config), { weight: 100 });
newItem.addSideEffect(Selector.rebuildSelectorSideEffectKey, (instance, config) => this.rebuildSelector(config), { weight: 100 });
// Add sideEffect to Selector, that updates the Item Value if this Value got updated
this.addSideEffect(Selector.rebuildItemSideEffectKey, (instance, config) => {
var _a, _b;
if (!((_a = instance.item) === null || _a === void 0 ? void 0 : _a.isPlaceholder))
(_b = instance.item) === null || _b === void 0 ? void 0 : _b.set(instance._value, Object.assign(Object.assign({}, config), {
sideEffects: {
enabled: true,
exclude: [Selector.rebuildSelectorSideEffectKey],
},
}));
}, { weight: 90 });
// Rebuild Selector for instantiating new 'selected' ItemKey properly

@@ -96,2 +110,3 @@ this.rebuildSelector(config);

item.removeSideEffect(Selector.rebuildSelectorSideEffectKey);
item.removeSideEffect(Selector.rebuildItemSideEffectKey);
if (item.isPlaceholder)

@@ -141,1 +156,2 @@ delete this.collection().data[this._itemKey];

Selector.rebuildSelectorSideEffectKey = 'rebuildSelector';
Selector.rebuildItemSideEffectKey = 'rebuildItem';

@@ -1,2 +0,2 @@

import { State, Agile, Observer, Event, StateConfigInterface } from '../internal';
import { State, Agile, Observer, Event, StateConfigInterface, Group, SideEffectConfigInterface } from '../internal';
export declare class Computed<ComputedValueType = any> extends State<ComputedValueType> {

@@ -48,3 +48,3 @@ agileInstance: () => Agile;

export interface ComputedConfigInterface extends StateConfigInterface {
computedDeps?: Array<Observer | State | Event>;
computedDeps?: Array<Observer | State | Event | Group>;
}

@@ -57,3 +57,3 @@ /**

background?: boolean;
sideEffects?: boolean;
sideEffects?: SideEffectConfigInterface;
}

@@ -60,0 +60,0 @@ /**

@@ -16,3 +16,3 @@ "use strict";

key: config.key,
deps: config.deps,
dependents: config.dependents,
});

@@ -43,3 +43,6 @@ this.deps = []; // All Dependencies of Computed (hardCoded and autoDetected)

background: false,
sideEffects: true,
sideEffects: {
enabled: true,
exclude: [],
},
});

@@ -61,3 +64,6 @@ this.ingest(config);

background: false,
sideEffects: true,
sideEffects: {
enabled: true,
exclude: [],
},
overwriteDeps: true,

@@ -64,0 +70,0 @@ });

@@ -1,2 +0,2 @@

import { Observer, RuntimeJob, ObserverKey, Event, SubscriptionContainer, IngestConfigInterface, RuntimeJobConfigInterface, RuntimeJobKey } from '../internal';
import { Observer, RuntimeJob, ObserverKey, Event, SubscriptionContainer } from '../internal';
export declare class EventObserver<PayloadType = any> extends Observer {

@@ -13,8 +13,2 @@ event: () => Event<PayloadType>;

* @internal
* Ingests Event into Runtime and causes Rerender on Components that got subscribed by the Event (Observer)
* @param config - Config
*/
trigger(config?: EventIngestConfigInterface): void;
/**
* @internal
* Performs Job from Runtime

@@ -26,3 +20,3 @@ * @param job - Job that gets performed

/**
* @param deps - Initial Dependencies of Event Observer
* @param dependents - Initial Dependents of Event Observer
* @param subs - Initial Subscriptions of Event Observer

@@ -32,11 +26,5 @@ * @param key - Key/Name of Event Observer

export interface CreateEventObserverConfigInterface {
deps?: Array<Observer>;
dependents?: Array<Observer>;
subs?: Array<SubscriptionContainer>;
key?: ObserverKey;
}
/**
* @param key - Key/Name of Job that gets created
*/
export interface EventIngestConfigInterface extends RuntimeJobConfigInterface, IngestConfigInterface {
key?: RuntimeJobKey;
}

@@ -14,3 +14,3 @@ "use strict";

super(event.agileInstance(), {
deps: config.deps,
dependents: config.dependents,
key: config.key,

@@ -22,28 +22,2 @@ subs: config.subs,

//=========================================================================================================
// Ingest
//=========================================================================================================
/**
* @internal
* Ingests Event into Runtime and causes Rerender on Components that got subscribed by the Event (Observer)
* @param config - Config
*/
trigger(config = {}) {
config = internal_1.defineConfig(config, {
perform: true,
background: false,
sideEffects: true,
force: false,
});
// Create Job
const job = new internal_1.RuntimeJob(this, {
force: config.force,
sideEffects: config.sideEffects,
background: config.background,
key: config.key || this._key,
});
this.agileInstance().runtime.ingest(job, {
perform: config.perform,
});
}
//=========================================================================================================
// Perform

@@ -50,0 +24,0 @@ //=========================================================================================================

@@ -110,3 +110,3 @@ import { Agile, EventJob, Observer } from '../internal';

* @param rerender - If triggering an Event should cause a rerender
* @param deps - Initial deps of State
* @param deps - Initial Dependents of Event
*/

@@ -120,3 +120,3 @@ export interface CreateEventConfigInterface {

rerender?: boolean;
deps?: Array<Observer>;
dependents?: Array<Observer>;
}

@@ -123,0 +123,0 @@ /**

@@ -25,3 +25,3 @@ "use strict";

overlap: false,
deps: [],
dependents: [],
});

@@ -31,3 +31,3 @@ this._key = config.key;

key: config.key,
deps: config.deps,
dependents: config.dependents,
});

@@ -186,3 +186,3 @@ this.enabled = config.enabled;

if (this.config.rerender)
this.observer.trigger();
this.observer.ingest();
this.uses++;

@@ -189,0 +189,0 @@ // Disable Event if maxUses got reached

@@ -55,2 +55,4 @@ "use strict";

job.performed = true;
// Ingest Dependents of Observer into Runtime
job.observer.dependents.forEach((observer) => observer.ingest({ perform: false }));
if (job.rerender)

@@ -57,0 +59,0 @@ this.jobsToRerender.push(job);

@@ -1,2 +0,2 @@

import { Agile, StateKey, RuntimeJob, SubscriptionContainer } from '../internal';
import { Agile, StateKey, RuntimeJob, SubscriptionContainer, IngestConfigInterface, CreateRuntimeJobConfigInterface } from '../internal';
export declare type ObserverKey = string | number;

@@ -6,3 +6,3 @@ export declare class Observer<ValueType = any> {

_key?: ObserverKey;
deps: Set<Observer>;
dependents: Set<Observer>;
subs: Set<SubscriptionContainer>;

@@ -30,2 +30,8 @@ value?: ValueType;

* @internal
* Ingests Observer into Runtime
* @param config - Configuration
*/
ingest(config?: ObserverIngestConfigInterface): void;
/**
* @internal
* Performs Job of Runtime

@@ -37,3 +43,3 @@ * @param job - Job that gets performed

* @internal
* Adds Dependency to Observer that will be ingested into the Runtime if this Observer changes
* Adds Dependent to Observer which gets ingested into the Runtime whenever this Observer mutates
* @param observer - Observer that will depend on this Observer

@@ -56,3 +62,3 @@ */

/**
* @param deps - Initial Dependencies of Observer
* @param deps - Initial Dependents of Observer
* @param subs - Initial Subscriptions of Observer

@@ -63,3 +69,3 @@ * @param key - Key/Name of Observer

export interface CreateObserverConfigInterface<ValueType = any> {
deps?: Array<Observer>;
dependents?: Array<Observer>;
subs?: Array<SubscriptionContainer>;

@@ -69,1 +75,3 @@ key?: ObserverKey;

}
export interface ObserverIngestConfigInterface extends CreateRuntimeJobConfigInterface, IngestConfigInterface {
}

@@ -15,6 +15,6 @@ "use strict";

var _a, _b;
this.deps = new Set(); // Observers that depends on this Observer
this.dependents = new Set(); // Observers that depend on this Observer
this.subs = new Set(); // SubscriptionContainers (Components) that this Observer has subscribed
config = internal_1.defineConfig(config, {
deps: [],
dependents: [],
subs: [],

@@ -25,3 +25,3 @@ });

this.value = config.value;
(_a = config.deps) === null || _a === void 0 ? void 0 : _a.forEach((observer) => this.depend(observer));
(_a = config.dependents) === null || _a === void 0 ? void 0 : _a.forEach((observer) => this.depend(observer));
(_b = config.subs) === null || _b === void 0 ? void 0 : _b.forEach((subscriptionContainer) => this.subscribe(subscriptionContainer));

@@ -44,2 +44,31 @@ }

//=========================================================================================================
// Ingest
//=========================================================================================================
/**
* @internal
* Ingests Observer into Runtime
* @param config - Configuration
*/
ingest(config = {}) {
config = internal_1.defineConfig(config, {
perform: true,
background: false,
sideEffects: {
enabled: true,
exclude: [],
},
force: false,
});
// Create Job
const job = new internal_1.RuntimeJob(this, {
force: config.force,
sideEffects: config.sideEffects,
background: config.background,
key: config.key || this._key,
});
this.agileInstance().runtime.ingest(job, {
perform: config.perform,
});
}
//=========================================================================================================
// Perform

@@ -60,8 +89,8 @@ //=========================================================================================================

* @internal
* Adds Dependency to Observer that will be ingested into the Runtime if this Observer changes
* Adds Dependent to Observer which gets ingested into the Runtime whenever this Observer mutates
* @param observer - Observer that will depend on this Observer
*/
depend(observer) {
if (!this.deps.has(observer))
this.deps.add(observer);
if (!this.dependents.has(observer))
this.dependents.add(observer);
}

@@ -68,0 +97,0 @@ //=========================================================================================================

@@ -33,4 +33,12 @@ import { Observer, SubscriptionContainer } from '../internal';

background?: boolean;
sideEffects?: boolean;
sideEffects?: SideEffectConfigInterface;
force?: boolean;
}
/**
* @param enabled - If SideEffects get executed
* @param exclude - SideEffect at Keys that doesn't get executed
*/
export interface SideEffectConfigInterface {
enabled?: boolean;
exclude?: string[];
}

@@ -17,3 +17,6 @@ "use strict";

background: false,
sideEffects: true,
sideEffects: {
enabled: true,
exclude: [],
},
force: false,

@@ -20,0 +23,0 @@ });

@@ -1,2 +0,2 @@

import { Agile, StorageKey, StateObserver, StatePersistent, Observer, PersistentKey, StateIngestConfigInterface, StateRuntimeJobConfigInterface } from '../internal';
import { Agile, StorageKey, StateObserver, StatePersistent, Observer, PersistentKey, StateIngestConfigInterface } from '../internal';
export declare class State<ValueType = any> {

@@ -14,3 +14,3 @@ agileInstance: () => Agile;

sideEffects: {
[key: string]: SideEffectInterface;
[key: string]: SideEffectInterface<State<ValueType>>;
};

@@ -63,3 +63,3 @@ computeMethod?: ComputeMethod<ValueType>;

*/
set(value: ValueType, config?: StateRuntimeJobConfigInterface): this;
set(value: ValueType, config?: StateIngestConfigInterface): this;
/**

@@ -83,3 +83,3 @@ * @internal

*/
undo(config?: StateRuntimeJobConfigInterface): this;
undo(config?: StateIngestConfigInterface): this;
/**

@@ -90,3 +90,3 @@ * @public

*/
reset(config?: StateRuntimeJobConfigInterface): this;
reset(config?: StateIngestConfigInterface): this;
/**

@@ -125,3 +125,3 @@ * @public

*/
onInaugurated(callback: StateWatcherCallback<ValueType>): void;
onInaugurated(callback: StateWatcherCallback<ValueType>): this;
/**

@@ -194,3 +194,3 @@ * @public

*/
addSideEffect(key: string, callback: SideEffectFunctionType, config?: AddSideEffectConfigInterface): this;
addSideEffect<Instance extends State<ValueType>>(key: string, callback: SideEffectFunctionType<Instance>, config?: AddSideEffectConfigInterface): this;
/**

@@ -234,3 +234,3 @@ * @internal

key?: StateKey;
deps?: Array<Observer>;
dependents?: Array<Observer>;
isPlaceholder?: boolean;

@@ -241,3 +241,3 @@ }

*/
export interface PatchConfigInterface extends StateRuntimeJobConfigInterface {
export interface PatchConfigInterface extends StateIngestConfigInterface {
addNewProperties?: boolean;

@@ -253,5 +253,5 @@ }

}
export declare type StateWatcherCallback<T = any> = (value: T) => void;
export declare type StateWatcherCallback<T = any> = (value: T, key: string) => void;
export declare type ComputeMethod<T = any> = (value: T) => T;
export declare type SideEffectFunctionType = (properties?: {
export declare type SideEffectFunctionType<Instance extends State<any>> = (instance: Instance, properties?: {
[key: string]: any;

@@ -263,4 +263,4 @@ }) => void;

*/
export interface SideEffectInterface {
callback: SideEffectFunctionType;
export interface SideEffectInterface<Instance extends State<any>> {
callback: SideEffectFunctionType<Instance>;
weight: number;

@@ -267,0 +267,0 @@ }

@@ -20,3 +20,3 @@ "use strict";

config = internal_1.defineConfig(config, {
deps: [],
dependents: [],
isPlaceholder: false,

@@ -28,3 +28,3 @@ });

key: config.key,
deps: config.deps,
dependents: config.dependents,
});

@@ -100,3 +100,6 @@ this.initialStateValue = internal_1.copy(initialValue);

config = internal_1.defineConfig(config, {
sideEffects: true,
sideEffects: {
enabled: true,
exclude: [],
},
background: false,

@@ -106,2 +109,3 @@ force: false,

overwrite: false,
perform: true,
});

@@ -189,3 +193,6 @@ // Check value has correct Type (js)

addNewProperties: true,
sideEffects: true,
sideEffects: {
enabled: true,
exclude: [],
},
background: false,

@@ -260,6 +267,7 @@ force: false,

const watcherKey = 'InauguratedWatcherKey';
this.watch(watcherKey, (value) => {
callback(value);
this.watch(watcherKey, (value, key) => {
callback(value, key);
this.removeWatcher(watcherKey);
});
return this;
}

@@ -341,3 +349,3 @@ //=========================================================================================================

get exists() {
return this._value !== undefined && !this.isPlaceholder;
return !this.isPlaceholder;
}

@@ -344,0 +352,0 @@ //=========================================================================================================

@@ -1,2 +0,2 @@

import { Observer, State, ObserverKey, SubscriptionContainer, IngestConfigInterface, StateRuntimeJob, StateRuntimeJobConfigInterface, RuntimeJobKey } from '../internal';
import { Observer, State, ObserverKey, SubscriptionContainer, IngestConfigInterface, StateRuntimeJob, CreateStateRuntimeJobConfigInterface } from '../internal';
export declare class StateObserver<ValueType = any> extends Observer {

@@ -39,3 +39,3 @@ state: () => State<ValueType>;

/**
* @param deps - Initial Dependencies of State Observer
* @param dependents - Initial Dependents of State Observer
* @param subs - Initial Subscriptions of State Observer

@@ -45,11 +45,7 @@ * @param key - Key/Name of State Observer

export interface CreateStateObserverConfigInterface {
deps?: Array<Observer>;
dependents?: Array<Observer>;
subs?: Array<SubscriptionContainer>;
key?: ObserverKey;
}
/**
* @param key - Key/Name of Job that gets created
*/
export interface StateIngestConfigInterface extends StateRuntimeJobConfigInterface, IngestConfigInterface {
key?: RuntimeJobKey;
export interface StateIngestConfigInterface extends CreateStateRuntimeJobConfigInterface, IngestConfigInterface {
}

@@ -48,3 +48,6 @@ "use strict";

background: false,
sideEffects: true,
sideEffects: {
enabled: true,
exclude: [],
},
force: false,

@@ -115,3 +118,3 @@ storage: true,

sideEffects(job) {
var _a;
var _a, _b, _c;
const state = job.observer.state();

@@ -121,5 +124,5 @@ // Call Watchers Functions

if (internal_1.isFunction(state.watchers[watcherKey]))
state.watchers[watcherKey](state.getPublicValue());
state.watchers[watcherKey](state.getPublicValue(), watcherKey);
// Call SideEffect Functions
if ((_a = job.config) === null || _a === void 0 ? void 0 : _a.sideEffects) {
if ((_b = (_a = job.config) === null || _a === void 0 ? void 0 : _a.sideEffects) === null || _b === void 0 ? void 0 : _b.enabled) {
const sideEffectArray = internal_1.createArrayFromObject(state.sideEffects);

@@ -129,10 +132,11 @@ sideEffectArray.sort(function (a, b) {

});
for (const sideEffect of sideEffectArray)
if (internal_1.isFunction(sideEffect.instance.callback))
sideEffect.instance.callback(job.config);
for (const sideEffect of sideEffectArray) {
if (internal_1.isFunction(sideEffect.instance.callback)) {
if (!((_c = job.config.sideEffects.exclude) === null || _c === void 0 ? void 0 : _c.includes(sideEffect.key)))
sideEffect.instance.callback(job.observer.state(), job.config);
}
}
}
// Ingest Dependencies of Observer into Runtime
state.observer.deps.forEach((observer) => observer instanceof StateObserver && observer.ingest({ perform: false }));
}
}
exports.StateObserver = StateObserver;

@@ -54,3 +54,5 @@ import { CreatePersistentConfigInterface, Persistent, PersistentKey, State, StorageKey } from '../internal';

*/
rebuildStorageSideEffect(state: State<ValueType>, key: PersistentKey, config?: any): void;
rebuildStorageSideEffect(state: State<ValueType>, key: PersistentKey, config?: {
[key: string]: any;
}): void;
}

@@ -123,3 +123,3 @@ "use strict";

// Add SideEffect to State, that updates the saved State Value depending on the current State Value
this.state().addSideEffect(StatePersistent.storeValueSideEffectKey, (config) => {
this.state().addSideEffect(StatePersistent.storeValueSideEffectKey, (instance, config) => {
this.rebuildStorageSideEffect(this.state(), _key, config);

@@ -126,0 +126,0 @@ }, { weight: 0 });

@@ -10,3 +10,6 @@ "use strict";

background: false,
sideEffects: true,
sideEffects: {
enabled: true,
exclude: [],
},
force: false,

@@ -13,0 +16,0 @@ storage: true,

{
"name": "@agile-ts/core",
"version": "0.0.10",
"version": "0.0.11",
"author": "BennoDev",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -6,29 +6,30 @@ <img src="https://raw.githubusercontent.com/agile-ts/agile/master/static/header_background.png" alt="AgileTs">

<br />
<p align="left">
<a href="https://github.com/agile-ts/agile">
<img src="https://img.shields.io/github/license/agile-ts/agile.svg?label=license&style=flat&colorA=293140&colorB=4a4872" alt="GitHub License"/>
</a>
<a href="https://npm.im/@agile-ts/core">
<img src="https://img.shields.io/bundlephobia/min/@agile-ts/core.svg?label=minified%20size&style=flat&colorA=293140&colorB=4a4872" alt="npm minified size"/>
</a>
<a href="https://npm.im/@agile-ts/core">
<img src="https://img.shields.io/npm/dt/@agile-ts/core.svg?label=downloads&style=flat&colorA=293140&colorB=4a4872" alt="npm total downloads"/>
</a>
</p>
<a href="https://github.com/agile-ts/agile">
<img src="https://img.shields.io/github/license/agile-ts/agile.svg?label=license&style=flat&colorA=293140&colorB=4a4872" alt="GitHub License"/></a>
<a href="https://npm.im/@agile-ts/core">
<img src="https://img.shields.io/bundlephobia/min/@agile-ts/core.svg?label=minified%20size&style=flat&colorA=293140&colorB=4a4872" alt="npm minified size"/></a>
<p align="left">
<a href="https://github.com/agile-ts/agile/actions?query=workflow%3ARelease">
<img src="https://github.com/agile-ts/agile/workflows/Release/badge.svg" alt="Build Status"/>
</a>
<a href="https://github.com/agile-ts/agile/actions?query=workflow%3A%22Test+All+Packages%22">
<img src="https://github.com/agile-ts/agile/workflows/Test%20All%20Packages/badge.svg" alt="Build Status"/>
</a>
</p>
<br />
<p align="left">
<a href="https://twitter.com/intent/tweet?text=I%20just%20discovered%20AgileTs%3B%20an%20awesome%2C%20spacy%20and%20overall%20easy%20to%20use%20State%20Manager.%0A%60%60%60ts%0Aconst%20MY_STATE%20%3D%20App.createState(%22Hello%20stranger%22)%3B%0AMY_STATE.set(%22Hello%20friend%22)%3B%0A%60%60%60%0Ahttps%3A%2F%2Fgithub.com%2Fagile-ts%2Fagile%2F"><img src="http://randojs.com/images/tweetShield.svg" alt="Tweet" height="20"/>
</a>
</p>
<a href="https://github.com/agile-ts/agile/actions?query=workflow%3ARelease">
<img src="https://github.com/agile-ts/agile/workflows/Release/badge.svg" alt="Build Status"/></a>
<a href="https://github.com/agile-ts/agile/actions?query=workflow%3A%22Test+All+Packages%22">
<img src="https://github.com/agile-ts/agile/workflows/Test%20All%20Packages/badge.svg" alt="Build Status"/></a>
<a href="https://codeclimate.com/github/agile-ts/agile/coverage.svg">
<img src="https://codeclimate.com/github/agile-ts/agile/badges/gpa.svg" alt="Maintainability"/></a>
<br />
<a href="https://npm.im/@agile-ts/core">
<img src="https://img.shields.io/npm/dm/@agile-ts/core.svg?label=downloads&style=flat&colorA=293140&colorB=4a4872" alt="npm monthly downloads"/></a>
<a href="https://npm.im/@agile-ts/core">
<img src="https://img.shields.io/npm/dt/@agile-ts/core.svg?label=downloads&style=flat&colorA=293140&colorB=4a4872" alt="npm total downloads"/></a>
<br />
<br />
<img src="https://raw.githubusercontent.com/agile-ts/agile/master/static/how_to_create_state_header.png" alt="How to create a State?"/>

@@ -149,3 +150,7 @@

<a href="https://codeclimate.com/github/agile-ts/agile/coverage.svg">
<img src="https://codeclimate.com/github/agile-ts/agile/badges/gpa.svg" alt="Maintainability"/>
</a>
<br />

@@ -152,0 +157,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc