@agile-ts/core
Advanced tools
Comparing version 0.1.1 to 0.1.2
# Change Log | ||
## 0.1.2 | ||
### Patch Changes | ||
- 2f2724f: #### :bug: Bug Fix | ||
- `core` | ||
- [#176](https://github.com/agile-ts/agile/pull/176) Fix persisting dynamically added items ([@bennodev19](https://github.com/bennodev19)) | ||
#### :nail_care: Polish | ||
- `api`, `core`, `event`, `logger`, `multieditor`, `react`, `utils` | ||
- [#177](https://github.com/agile-ts/agile/pull/177) Optimize default configurations ([@bennodev19](https://github.com/bennodev19)) | ||
#### Committers: 1 | ||
- BennoDev ([@bennodev19](https://github.com/bennodev19)) | ||
- Updated dependencies [2f2724f] | ||
- @agile-ts/logger@0.0.7 | ||
- @agile-ts/utils@0.0.7 | ||
## 0.1.1 | ||
@@ -4,0 +26,0 @@ |
@@ -7,3 +7,9 @@ "use strict"; | ||
constructor(config = {}) { | ||
config = Object.assign({ localStorage: false, waitForMount: true, bindGlobal: false, autoIntegrate: true, bucket: true }, config); | ||
config = internal_1.defineConfig(config, { | ||
localStorage: false, | ||
waitForMount: true, | ||
bindGlobal: false, | ||
autoIntegrate: true, | ||
bucket: true, | ||
}); | ||
this.config = { | ||
@@ -32,3 +38,5 @@ waitForMount: config.waitForMount, | ||
createState(initialValue, config = {}) { | ||
return internal_1.createState(initialValue, Object.assign(Object.assign({}, config), { agileInstance: this })); | ||
return internal_1.createState(initialValue, internal_1.defineConfig(config, { | ||
agileInstance: this, | ||
})); | ||
} | ||
@@ -41,3 +49,3 @@ createCollection(config) { | ||
if (Array.isArray(configOrDeps)) { | ||
_config = internal_1.flatMerge(_config, { | ||
_config = internal_1.defineConfig(_config, { | ||
computedDeps: configOrDeps, | ||
@@ -49,3 +57,5 @@ agileInstance: this, | ||
if (configOrDeps) | ||
_config = Object.assign(Object.assign({}, configOrDeps), { agileInstance: this }); | ||
_config = internal_1.defineConfig(configOrDeps, { | ||
agileInstance: this, | ||
}); | ||
} | ||
@@ -52,0 +62,0 @@ return internal_1.createComputed(computeFunction, _config); |
@@ -19,3 +19,7 @@ "use strict"; | ||
}); | ||
config = Object.assign({ instantiate: true, storageKeys: [], defaultStorageKey: null }, config); | ||
config = internal_1.defineConfig(config, { | ||
instantiate: true, | ||
storageKeys: [], | ||
defaultStorageKey: null, | ||
}); | ||
this.collection = () => collection; | ||
@@ -49,3 +53,3 @@ this.instantiatePersistent({ | ||
const loadValuesIntoCollection = () => __awaiter(this, void 0, void 0, function* () { | ||
var _a, _b; | ||
var _a, _b, _c; | ||
const defaultGroup = this.collection().getDefaultGroup(); | ||
@@ -68,2 +72,3 @@ if (defaultGroup == null) | ||
item.persist(itemStorageKey, { | ||
loadValue: false, | ||
defaultStorageKey: this.config.defaultStorageKey || undefined, | ||
@@ -73,6 +78,8 @@ storageKeys: this.storageKeys, | ||
}); | ||
if ((_b = item === null || item === void 0 ? void 0 : item.persistent) === null || _b === void 0 ? void 0 : _b.ready) | ||
yield item.persistent.initialLoading(); | ||
} | ||
else { | ||
const dummyItem = this.collection().createPlaceholderItem(itemKey); | ||
dummyItem === null || dummyItem === void 0 ? void 0 : dummyItem.persist(itemStorageKey, { | ||
const placeholderItem = this.collection().getItemWithReference(itemKey); | ||
placeholderItem === null || placeholderItem === void 0 ? void 0 : placeholderItem.persist(itemStorageKey, { | ||
loadValue: false, | ||
@@ -83,6 +90,11 @@ defaultStorageKey: this.config.defaultStorageKey, | ||
}); | ||
if ((_b = dummyItem === null || dummyItem === void 0 ? void 0 : dummyItem.persistent) === null || _b === void 0 ? void 0 : _b.ready) { | ||
const loadedPersistedValueIntoItem = yield dummyItem.persistent.loadPersistedValue(itemStorageKey); | ||
if (loadedPersistedValueIntoItem) | ||
this.collection().assignItem(dummyItem, { overwrite: false }); | ||
if ((_c = placeholderItem === null || placeholderItem === void 0 ? void 0 : placeholderItem.persistent) === null || _c === void 0 ? void 0 : _c.ready) { | ||
const loadedPersistedValueIntoItem = yield placeholderItem.persistent.loadPersistedValue(); | ||
if (loadedPersistedValueIntoItem) { | ||
this.collection().assignItem(placeholderItem, { | ||
overwrite: true, | ||
}); | ||
placeholderItem.isPersisted = true; | ||
this.collection().size += 1; | ||
} | ||
} | ||
@@ -89,0 +101,0 @@ } |
@@ -7,3 +7,3 @@ "use strict"; | ||
constructor(group, config = {}) { | ||
super(group.agileInstance(), Object.assign(Object.assign({}, config), { value: group._output })); | ||
super(group.agileInstance(), internal_1.defineConfig(config, { value: group._output })); | ||
this.group = () => group; | ||
@@ -18,6 +18,12 @@ this.nextGroupOutput = internal_1.copy(group._output); | ||
const group = this.group(); | ||
config = Object.assign({ perform: true, background: false, sideEffects: { | ||
config = internal_1.defineConfig(config, { | ||
perform: true, | ||
background: false, | ||
sideEffects: { | ||
enabled: true, | ||
exclude: [], | ||
}, force: false, maxTriesToUpdate: 3 }, config); | ||
}, | ||
force: false, | ||
maxTriesToUpdate: 3, | ||
}); | ||
if (group.isPlaceholder) { | ||
@@ -24,0 +30,0 @@ config.force = true; |
@@ -61,3 +61,6 @@ "use strict"; | ||
let newGroupValue = internal_1.copy(this.nextStateValue); | ||
config = Object.assign({ method: 'push', overwrite: false }, config); | ||
internal_1.defineConfig(config, { | ||
method: 'push', | ||
overwrite: false, | ||
}); | ||
_itemKeys.forEach((itemKey) => { | ||
@@ -107,3 +110,8 @@ if (!this.collection().getItem(itemKey)) | ||
} | ||
_config = Object.assign({ loadValue: true, followCollectionPersistKeyPattern: true, storageKeys: [], defaultStorageKey: null }, _config); | ||
_config = internal_1.defineConfig(_config, { | ||
loadValue: true, | ||
followCollectionPersistKeyPattern: true, | ||
storageKeys: [], | ||
defaultStorageKey: null, | ||
}); | ||
if (_config.followCollectionPersistKeyPattern) { | ||
@@ -110,0 +118,0 @@ key = internal_1.CollectionPersistent.getGroupStorageKey(key || this._key, this.collection()._key); |
@@ -15,3 +15,8 @@ "use strict"; | ||
let _config = typeof config === 'function' ? config(this) : config; | ||
_config = Object.assign({ primaryKey: 'id', groups: {}, selectors: {}, defaultGroupKey: 'default' }, _config); | ||
_config = internal_1.defineConfig(_config, { | ||
primaryKey: 'id', | ||
groups: {}, | ||
selectors: {}, | ||
defaultGroupKey: 'default', | ||
}); | ||
this._key = _config.key; | ||
@@ -107,3 +112,8 @@ this.config = { | ||
const primaryKey = this.config.primaryKey; | ||
config = Object.assign({ method: 'push', background: false, patch: false, select: false }, config); | ||
config = internal_1.defineConfig(config, { | ||
method: 'push', | ||
background: false, | ||
patch: false, | ||
select: false, | ||
}); | ||
if (!_groupKeys.includes(defaultGroupKey)) | ||
@@ -147,3 +157,6 @@ _groupKeys.push(defaultGroupKey); | ||
const primaryKey = this.config.primaryKey; | ||
config = Object.assign({ patch: true, background: false }, config); | ||
config = internal_1.defineConfig(config, { | ||
patch: true, | ||
background: false, | ||
}); | ||
if (item == null) { | ||
@@ -204,3 +217,5 @@ internal_1.LogCodeManager.log('1B:03:00', [itemKey, this._key]); | ||
getGroup(groupKey, config = {}) { | ||
config = Object.assign({ notExisting: false }, config); | ||
config = internal_1.defineConfig(config, { | ||
notExisting: false, | ||
}); | ||
const group = groupKey ? this.groups[groupKey] : undefined; | ||
@@ -262,3 +277,5 @@ if (group == null || (!config.notExisting && !group.exists)) | ||
getSelector(selectorKey, config = {}) { | ||
config = Object.assign({ notExisting: false }, config); | ||
config = internal_1.defineConfig(config, { | ||
notExisting: false, | ||
}); | ||
const selector = selectorKey ? this.selectors[selectorKey] : undefined; | ||
@@ -298,3 +315,5 @@ if (selector == null || (!config.notExisting && !selector.exists)) | ||
getItem(itemKey, config = {}) { | ||
config = Object.assign({ notExisting: false }, config); | ||
config = internal_1.defineConfig(config, { | ||
notExisting: false, | ||
}); | ||
const item = itemKey != null ? this.data[itemKey] : undefined; | ||
@@ -331,3 +350,5 @@ if (item == null || (!config.notExisting && !item.exists)) | ||
getAllItems(config = {}) { | ||
config = Object.assign({ notExisting: false }, config); | ||
config = internal_1.defineConfig(config, { | ||
notExisting: false, | ||
}); | ||
const defaultGroup = this.getDefaultGroup(); | ||
@@ -359,3 +380,7 @@ let items = []; | ||
} | ||
_config = Object.assign({ loadValue: true, storageKeys: [], defaultStorageKey: null }, _config); | ||
_config = internal_1.defineConfig(_config, { | ||
loadValue: true, | ||
storageKeys: [], | ||
defaultStorageKey: null, | ||
}); | ||
if (this.persistent != null && this.isPersisted) | ||
@@ -412,3 +437,5 @@ return this; | ||
const item = this.getItem(oldItemKey, { notExisting: true }); | ||
config = Object.assign({ background: false }, config); | ||
config = internal_1.defineConfig(config, { | ||
background: false, | ||
}); | ||
if (item == null || oldItemKey === newItemKey) | ||
@@ -486,3 +513,6 @@ return false; | ||
removeItems(itemKeys, config = {}) { | ||
config = Object.assign({ notExisting: false, removeSelector: false }, config); | ||
config = internal_1.defineConfig(config, { | ||
notExisting: false, | ||
removeSelector: false, | ||
}); | ||
const _itemKeys = internal_1.normalizeArray(itemKeys); | ||
@@ -519,3 +549,6 @@ _itemKeys.forEach((itemKey) => { | ||
assignData(data, config = {}) { | ||
config = Object.assign({ patch: false, background: false }, config); | ||
config = internal_1.defineConfig(config, { | ||
patch: false, | ||
background: false, | ||
}); | ||
const _data = internal_1.copy(data); | ||
@@ -552,3 +585,6 @@ const primaryKey = this.config.primaryKey; | ||
assignItem(item, config = {}) { | ||
config = Object.assign({ overwrite: false, background: false }, config); | ||
config = internal_1.defineConfig(config, { | ||
overwrite: false, | ||
background: false, | ||
}); | ||
const primaryKey = this.config.primaryKey; | ||
@@ -584,6 +620,9 @@ let itemKey = item._value[primaryKey]; | ||
rebuildGroupsThatIncludeItemKey(itemKey, config = {}) { | ||
config = Object.assign({ background: false, sideEffects: { | ||
config = internal_1.defineConfig(config, { | ||
background: false, | ||
sideEffects: { | ||
enabled: true, | ||
exclude: [], | ||
} }, config); | ||
}, | ||
}); | ||
for (const groupKey in this.groups) { | ||
@@ -590,0 +629,0 @@ const group = this.getGroup(groupKey); |
@@ -19,6 +19,12 @@ "use strict"; | ||
super.setKey(value); | ||
config = Object.assign({ sideEffects: { | ||
config = internal_1.defineConfig(config, { | ||
sideEffects: { | ||
enabled: true, | ||
exclude: [], | ||
}, background: false, force: false, storage: true, overwrite: false }, config); | ||
}, | ||
background: false, | ||
force: false, | ||
storage: true, | ||
overwrite: false, | ||
}); | ||
if (value == null) | ||
@@ -42,3 +48,8 @@ return this; | ||
} | ||
_config = Object.assign({ loadValue: true, followCollectionPersistKeyPattern: true, storageKeys: [], defaultStorageKey: null }, _config); | ||
_config = internal_1.defineConfig(_config, { | ||
loadValue: true, | ||
followCollectionPersistKeyPattern: true, | ||
storageKeys: [], | ||
defaultStorageKey: null, | ||
}); | ||
if (_config.followCollectionPersistKeyPattern) { | ||
@@ -45,0 +56,0 @@ key = internal_1.CollectionPersistent.getItemStorageKey(key || this._key, this.collection()._key); |
@@ -7,3 +7,5 @@ "use strict"; | ||
constructor(collection, itemKey, config = {}) { | ||
config = Object.assign({ isPlaceholder: false }, config); | ||
config = internal_1.defineConfig(config, { | ||
isPlaceholder: false, | ||
}); | ||
super(collection.agileInstance(), null, config); | ||
@@ -33,6 +35,12 @@ this.collection = () => collection; | ||
var _a, _b; | ||
config = Object.assign({ background: false, sideEffects: { | ||
config = internal_1.defineConfig(config, { | ||
background: false, | ||
sideEffects: { | ||
enabled: true, | ||
exclude: [], | ||
}, force: false, overwrite: (_b = (_a = this._item) === null || _a === void 0 ? void 0 : _a.isPlaceholder) !== null && _b !== void 0 ? _b : false, storage: true }, config); | ||
}, | ||
force: false, | ||
overwrite: (_b = (_a = this._item) === null || _a === void 0 ? void 0 : _a.isPlaceholder) !== null && _b !== void 0 ? _b : false, | ||
storage: true, | ||
}); | ||
if ((!this.collection().isInstantiated || this.hasSelected(itemKey)) && | ||
@@ -39,0 +47,0 @@ !config.force) |
@@ -22,3 +22,6 @@ "use strict"; | ||
this.hardCodedDeps = []; | ||
config = Object.assign({ computedDeps: [], autodetect: !internal_1.isAsyncFunction(computeFunction) }, config); | ||
config = internal_1.defineConfig(config, { | ||
computedDeps: [], | ||
autodetect: !internal_1.isAsyncFunction(computeFunction), | ||
}); | ||
this.agileInstance = () => agileInstance; | ||
@@ -37,3 +40,5 @@ this.computeFunction = computeFunction; | ||
recompute(config = {}) { | ||
config = Object.assign({ autodetect: false }, config); | ||
config = internal_1.defineConfig(config, { | ||
autodetect: false, | ||
}); | ||
this.compute({ autodetect: config.autodetect }).then((result) => { | ||
@@ -45,3 +50,5 @@ this.observers['value'].ingestValue(result, internal_1.removeProperties(config, ['autodetect'])); | ||
updateComputeFunction(computeFunction, deps = [], config = {}) { | ||
config = Object.assign({ autodetect: this.config.autodetect }, config); | ||
config = internal_1.defineConfig(config, { | ||
autodetect: this.config.autodetect, | ||
}); | ||
this.deps.forEach((observer) => { | ||
@@ -61,3 +68,5 @@ observer.removeDependent(this.observers['value']); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
config = Object.assign({ autodetect: this.config.autodetect }, config); | ||
config = internal_1.defineConfig(config, { | ||
autodetect: this.config.autodetect, | ||
}); | ||
if (config.autodetect) | ||
@@ -64,0 +73,0 @@ internal_1.ComputedTracker.track(); |
@@ -10,3 +10,3 @@ "use strict"; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
@@ -13,0 +13,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -18,3 +18,5 @@ "use strict"; | ||
this.integrations = new Set(); | ||
config = Object.assign({ autoIntegrate: true }, config); | ||
config = internal_1.defineConfig(config, { | ||
autoIntegrate: true, | ||
}); | ||
this.agileInstance = () => agileInstance; | ||
@@ -21,0 +23,0 @@ if (config.autoIntegrate) { |
@@ -10,3 +10,3 @@ "use strict"; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
@@ -13,0 +13,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -30,3 +30,3 @@ "use strict"; | ||
'12:03:00': 'No valid persist Key found! Provide a valid key or assign one to the parent instance.', | ||
'12:03:01': 'No persist Storage Key found! Please specify at least one Storage Key.', | ||
'12:03:01': 'No valid persist Storage Key found! Please specify at least one Storage Key to use the persist functionality.', | ||
'12:03:02': "Couldn't validate Persistent '${0}'." + | ||
@@ -109,3 +109,3 @@ "The Storage with the key/name '${1}' doesn't exists!`", | ||
const logger = exports.LogCodeManager.getLogger(); | ||
if (!(logger === null || logger === void 0 ? void 0 : logger.isActive)) | ||
if (logger != null && !logger.isActive) | ||
return; | ||
@@ -117,3 +117,3 @@ const logType = logCodeTypes[logCode.substr(3, 2)]; | ||
if (logType === 'error' || logType === 'warn') | ||
console[logType](getLog(logCode, replacers)); | ||
console[logType](`Agile: ${getLog(logCode, replacers)}`); | ||
return; | ||
@@ -125,3 +125,3 @@ } | ||
const logger = exports.LogCodeManager.getLogger(); | ||
if (!(logger === null || logger === void 0 ? void 0 : logger.isActive)) | ||
if (logger != null && !logger.isActive) | ||
return; | ||
@@ -128,0 +128,0 @@ const logType = logCodeTypes[logCode.substr(3, 2)]; |
@@ -16,3 +16,5 @@ "use strict"; | ||
ingest(job, config = {}) { | ||
config = Object.assign({ perform: !this.isPerformingJobs }, config); | ||
config = internal_1.defineConfig(config, { | ||
perform: !this.isPerformingJobs, | ||
}); | ||
this.jobQueue.push(job); | ||
@@ -19,0 +21,0 @@ internal_1.LogCodeManager.logIfTags(['runtime'], '16:01:00', [job._key], job); |
@@ -10,3 +10,6 @@ "use strict"; | ||
this.subscribedTo = new Set(); | ||
config = Object.assign({ dependents: [], subs: [] }, config); | ||
config = internal_1.defineConfig(config, { | ||
dependents: [], | ||
subs: [], | ||
}); | ||
this.agileInstance = () => agileInstance; | ||
@@ -27,6 +30,11 @@ this._key = config.key; | ||
var _a; | ||
config = Object.assign({ perform: true, background: false, sideEffects: { | ||
config = internal_1.defineConfig(config, { | ||
perform: true, | ||
background: false, | ||
sideEffects: { | ||
enabled: true, | ||
exclude: [], | ||
}, force: false }, config); | ||
}, | ||
force: false, | ||
}); | ||
const job = new internal_1.RuntimeJob(this, { | ||
@@ -33,0 +41,0 @@ force: config.force, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RuntimeJob = void 0; | ||
const internal_1 = require("../internal"); | ||
class RuntimeJob { | ||
@@ -9,6 +10,11 @@ constructor(observer, config = {}) { | ||
this.performed = false; | ||
config = Object.assign({ background: false, sideEffects: { | ||
config = internal_1.defineConfig(config, { | ||
background: false, | ||
sideEffects: { | ||
enabled: true, | ||
exclude: [], | ||
}, force: false, maxTriesToUpdate: 3 }, config); | ||
}, | ||
force: false, | ||
maxTriesToUpdate: 3, | ||
}); | ||
this.config = { | ||
@@ -15,0 +21,0 @@ background: config.background, |
@@ -11,3 +11,5 @@ "use strict"; | ||
this.isObjectBased = false; | ||
config = Object.assign({ key: internal_1.generateId() }, config); | ||
config = internal_1.defineConfig(config, { | ||
key: internal_1.generateId(), | ||
}); | ||
this.subscribers = new Set(); | ||
@@ -14,0 +16,0 @@ this.key = config.key; |
@@ -13,3 +13,5 @@ "use strict"; | ||
subscribe(integrationInstance, subs, config = {}) { | ||
config = Object.assign({ waitForMount: this.agileInstance().config.waitForMount }, config); | ||
config = internal_1.defineConfig(config, { | ||
waitForMount: this.agileInstance().config.waitForMount, | ||
}); | ||
const subscriptionContainer = internal_1.isFunction(integrationInstance) | ||
@@ -16,0 +18,0 @@ ? this.createCallbackSubscriptionContainer(integrationInstance, subs, config) |
@@ -19,3 +19,5 @@ "use strict"; | ||
function createState(initialValue, config = {}) { | ||
config = Object.assign({ agileInstance: sharedAgileInstance }, config); | ||
config = internal_1.defineConfig(config, { | ||
agileInstance: sharedAgileInstance, | ||
}); | ||
return new internal_1.State(config.agileInstance, initialValue, internal_1.removeProperties(config, ['agileInstance'])); | ||
@@ -31,3 +33,3 @@ } | ||
if (Array.isArray(configOrDeps)) { | ||
_config = internal_1.flatMerge(_config, { | ||
_config = internal_1.defineConfig(_config, { | ||
computedDeps: configOrDeps, | ||
@@ -40,5 +42,5 @@ }); | ||
} | ||
_config = Object.assign({ agileInstance: sharedAgileInstance }, _config); | ||
_config = internal_1.defineConfig(_config, { agileInstance: sharedAgileInstance }); | ||
return new internal_1.Computed(_config.agileInstance, computeFunction, internal_1.removeProperties(_config, ['agileInstance'])); | ||
} | ||
exports.createComputed = createComputed; |
@@ -13,3 +13,6 @@ "use strict"; | ||
this.watchers = {}; | ||
config = Object.assign({ dependents: [], isPlaceholder: false }, config); | ||
config = internal_1.defineConfig(config, { | ||
dependents: [], | ||
isPlaceholder: false, | ||
}); | ||
this.agileInstance = () => agileInstance; | ||
@@ -56,3 +59,5 @@ this._key = config.key; | ||
set(value, config = {}) { | ||
config = Object.assign({ force: false }, config); | ||
config = internal_1.defineConfig(config, { | ||
force: false, | ||
}); | ||
const _value = internal_1.isFunction(value) | ||
@@ -94,3 +99,5 @@ ? value(internal_1.copy(this._value)) | ||
patch(targetWithChanges, config = {}) { | ||
config = Object.assign({ addNewProperties: true }, config); | ||
config = internal_1.defineConfig(config, { | ||
addNewProperties: true, | ||
}); | ||
if (!internal_1.isValidObject(this.nextStateValue, true)) { | ||
@@ -162,3 +169,7 @@ internal_1.LogCodeManager.log('14:03:02'); | ||
} | ||
_config = Object.assign({ loadValue: true, storageKeys: [], defaultStorageKey: null }, _config); | ||
_config = internal_1.defineConfig(_config, { | ||
loadValue: true, | ||
storageKeys: [], | ||
defaultStorageKey: null, | ||
}); | ||
if (this.persistent != null && this.isPersisted) | ||
@@ -253,3 +264,5 @@ return this; | ||
addSideEffect(key, callback, config = {}) { | ||
config = Object.assign({ weight: 10 }, config); | ||
config = internal_1.defineConfig(config, { | ||
weight: 10, | ||
}); | ||
if (!internal_1.isFunction(callback)) { | ||
@@ -256,0 +269,0 @@ internal_1.LogCodeManager.log('00:03:01', ['Side Effect Callback', 'function']); |
@@ -7,3 +7,5 @@ "use strict"; | ||
constructor(state, config = {}) { | ||
super(state.agileInstance(), Object.assign(Object.assign({}, config), { value: state._value })); | ||
super(state.agileInstance(), internal_1.defineConfig(config, { | ||
value: state._value, | ||
})); | ||
this.state = () => state; | ||
@@ -26,6 +28,14 @@ this.nextStateValue = internal_1.copy(state._value); | ||
const state = this.state(); | ||
config = Object.assign({ perform: true, background: false, sideEffects: { | ||
config = internal_1.defineConfig(config, { | ||
perform: true, | ||
background: false, | ||
sideEffects: { | ||
enabled: true, | ||
exclude: [], | ||
}, force: false, storage: true, overwrite: false, maxTriesToUpdate: 3 }, config); | ||
}, | ||
force: false, | ||
storage: true, | ||
overwrite: false, | ||
maxTriesToUpdate: 3, | ||
}); | ||
if (state.isPlaceholder) { | ||
@@ -32,0 +42,0 @@ config.force = true; |
@@ -19,3 +19,7 @@ "use strict"; | ||
}); | ||
config = Object.assign({ instantiate: true, storageKeys: [], defaultStorageKey: null }, config); | ||
config = internal_1.defineConfig(config, { | ||
instantiate: true, | ||
storageKeys: [], | ||
defaultStorageKey: null, | ||
}); | ||
this.state = () => state; | ||
@@ -22,0 +26,0 @@ this.instantiatePersistent({ |
@@ -8,6 +8,13 @@ "use strict"; | ||
super(observer, config); | ||
config = Object.assign({ background: false, sideEffects: { | ||
config = internal_1.defineConfig(config, { | ||
background: false, | ||
sideEffects: { | ||
enabled: true, | ||
exclude: [], | ||
}, force: false, storage: true, overwrite: false, maxTriesToUpdate: 3 }, config); | ||
}, | ||
force: false, | ||
storage: true, | ||
overwrite: false, | ||
maxTriesToUpdate: 3, | ||
}); | ||
this.config = { | ||
@@ -14,0 +21,0 @@ background: config.background, |
@@ -10,3 +10,6 @@ "use strict"; | ||
this.agileInstance = () => agileInstance; | ||
config = Object.assign({ localStorage: false, defaultStorageKey: null }, config); | ||
config = internal_1.defineConfig(config, { | ||
localStorage: false, | ||
defaultStorageKey: null, | ||
}); | ||
this.config = { defaultStorageKey: config.defaultStorageKey }; | ||
@@ -13,0 +16,0 @@ if (config.localStorage) |
@@ -21,3 +21,7 @@ "use strict"; | ||
this._key = Persistent.placeHolderKey; | ||
config = Object.assign({ instantiate: true, storageKeys: [], defaultStorageKey: null }, config); | ||
config = internal_1.defineConfig(config, { | ||
instantiate: true, | ||
storageKeys: [], | ||
defaultStorageKey: null, | ||
}); | ||
this.agileInstance().storages.persistentInstances.add(this); | ||
@@ -69,3 +73,3 @@ this.config = { defaultStorageKey: config.defaultStorageKey }; | ||
} | ||
if (!this.config.defaultStorageKey || this.storageKeys.length <= 0) { | ||
if (this.config.defaultStorageKey == null || this.storageKeys.length <= 0) { | ||
internal_1.LogCodeManager.log('12:03:01'); | ||
@@ -86,7 +90,10 @@ isValid = false; | ||
const _storageKeys = internal_1.copy(storageKeys); | ||
if (defaultStorageKey && !_storageKeys.includes(defaultStorageKey)) | ||
if (defaultStorageKey != null && !_storageKeys.includes(defaultStorageKey)) | ||
_storageKeys.push(defaultStorageKey); | ||
if (_storageKeys.length <= 0) { | ||
this.config.defaultStorageKey = storages.config.defaultStorageKey; | ||
_storageKeys.push(storages.config.defaultStorageKey); | ||
const defaultStorageKey = storages.config.defaultStorageKey; | ||
if (defaultStorageKey != null) { | ||
this.config.defaultStorageKey = defaultStorageKey; | ||
_storageKeys.push(storages.config.defaultStorageKey); | ||
} | ||
} | ||
@@ -93,0 +100,0 @@ else { |
@@ -8,3 +8,6 @@ "use strict"; | ||
this.ready = false; | ||
config = Object.assign({ prefix: 'agile', async: false }, config); | ||
config = internal_1.defineConfig(config, { | ||
prefix: 'agile', | ||
async: false, | ||
}); | ||
this.key = config.key; | ||
@@ -11,0 +14,0 @@ this.methods = config.methods; |
@@ -113,3 +113,3 @@ "use strict"; | ||
exports.globalBind = globalBind; | ||
exports.runsOnServer = () => { | ||
const runsOnServer = () => { | ||
return !(typeof window !== 'undefined' && | ||
@@ -119,1 +119,2 @@ typeof window.document !== 'undefined' && | ||
}; | ||
exports.runsOnServer = runsOnServer; |
{ | ||
"name": "@agile-ts/core", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"author": "BennoDev", | ||
@@ -47,6 +47,6 @@ "license": "MIT", | ||
"dependencies": { | ||
"@agile-ts/utils": "^0.0.6" | ||
"@agile-ts/utils": "^0.0.7" | ||
}, | ||
"peerDependencies": { | ||
"@agile-ts/logger": "^0.0.6" | ||
"@agile-ts/logger": "^0.0.7" | ||
}, | ||
@@ -53,0 +53,0 @@ "peerDependenciesMeta": { |
308927
7279
+ Added@agile-ts/logger@0.0.7(transitive)
+ Added@agile-ts/utils@0.0.7(transitive)
- Removed@agile-ts/logger@0.0.6(transitive)
- Removed@agile-ts/utils@0.0.6(transitive)
Updated@agile-ts/utils@^0.0.7