From 037d1ae8206fba646d8b409296de6ebb6f295b8a Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Fri, 5 Mar 2021 15:54:29 +0100
Subject: [PATCH 01/35] added select method
---
packages/core/src/collection/index.ts | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/packages/core/src/collection/index.ts b/packages/core/src/collection/index.ts
index fff70ba3..b4d8bf32 100644
--- a/packages/core/src/collection/index.ts
+++ b/packages/core/src/collection/index.ts
@@ -509,6 +509,18 @@ export class Collection {
return selector;
}
+ //=========================================================================================================
+ // Select
+ //=========================================================================================================
+ /**
+ * @public
+ * Creates new Selector that represents an Item of the Collection
+ * @param itemKey - Key of Item which the Selector represents
+ */
+ public select(itemKey: ItemKey): Selector {
+ return this.createSelector(itemKey, itemKey);
+ }
+
//=========================================================================================================
// Has Selector
//=========================================================================================================
From 6aae5fae8b89a1c90beaf7c426de0ca4cb2743e9 Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Tue, 9 Mar 2021 06:53:37 +0100
Subject: [PATCH 02/35] removed invalid url warning, since the fetch function
which gets called drops a Warning/Error anyway
---
.../functional-component-ts/src/core/index.ts | 22 +++++++++++++++++++
packages/api/src/index.ts | 4 ++--
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/examples/react/functional-component-ts/src/core/index.ts b/examples/react/functional-component-ts/src/core/index.ts
index d28c88da..b812c014 100644
--- a/examples/react/functional-component-ts/src/core/index.ts
+++ b/examples/react/functional-component-ts/src/core/index.ts
@@ -1,4 +1,5 @@
import { Agile, clone, Logger } from '@agile-ts/core';
+import API from '@agile-ts/api';
export const App = new Agile({
logConfig: { level: Logger.level.DEBUG },
@@ -94,3 +95,24 @@ logger.trace('This is a Trace');
logger.if.tag(['coreWarning']).warn('My core Warning');
logger.if.tag(['randomDebug']).debug('My random Debug');
logger.table('Test Table', { test: 'test', test1: 'test1' });
+
+const api = new API({
+ timeout: 10000,
+ options: {
+ credentials: undefined,
+ },
+});
+
+// testing some urls
+api
+ .with({
+ baseURL: `https://api.npmjs.org/downloads/point/2020-08-24:2020-09-24/@agile-ts/core`,
+ })
+ .get('');
+
+// testing some urls
+api
+ .with({
+ baseURL: `https://api`,
+ })
+ .get('');
diff --git a/packages/api/src/index.ts b/packages/api/src/index.ts
index 50879924..acecb4b9 100644
--- a/packages/api/src/index.ts
+++ b/packages/api/src/index.ts
@@ -139,8 +139,8 @@ export default class API {
}/${endpoint}`;
// Warning if fullUrl might be invalid
- if (!isValidUrl(fullUrl))
- console.warn(`Url '${fullUrl}' might be invalid!`);
+ // if (!isValidUrl(fullUrl))
+ // Agile.logger.warn(`Url '${fullUrl}' might be invalid!`);
// Send Request with Timeout
if (this.config.timeout) {
From 31956b755dbc84c9c9f50f9267effe786451b64e Mon Sep 17 00:00:00 2001
From: BennoDev <57860196+bennodev19@users.noreply.github.com>
Date: Tue, 9 Mar 2021 20:24:22 +0100
Subject: [PATCH 03/35] optimized readme
---
README.md | 29 +++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)
diff --git a/README.md b/README.md
index dd28e64c..b1a1eb54 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
- > **AgileTs is a spacy, fast, simple State Management Framework**
+ > AgileTs is a global, simple, spacy State and Logic Framework
@@ -29,7 +29,7 @@
-
+
@@ -72,10 +72,9 @@ More examples can be found in the [Example Section](../examples/Indroduction.md)
-AgileTs is a simple, fast and well tested State Management Framework which is implemented in TypeScript.
-It's more flexible and boilerplate free than Redux and has an interesting approach to reducing
-the size of a codebase through a centralized memory design pattern.
-The philosophy behind AgileTs is simple:
+AgileTs is a global, simple, well-tested State Management Framework implemented in TypeScript.
+It's more flexible and boilerplate-free than frameworks like Redux and has a powerful approach to reducing the codebase size through a
+centralized memory design pattern. The philosophy behind AgileTs is simple:
### π
Straightforward
Write minimalistic, boilerplate free code that captures your intent.
@@ -91,16 +90,15 @@ Write minimalistic, boilerplate free code that captures your intent.
MY_COLLECTION.collect({id: 1, name: "Frank"});
MY_COLLECTION.collect({id: 2, name: "Dieter"});
```
-- Mutate or Check States with simple Functions
+- Mutate and Check States with simple Functions
```ts
MY_STATE.undo(); // Undo latest change
MY_STATE.is({hello: "jeff"}); // Check if State has the Value '{hello: "jeff"}'
```
### π€Έβ Flexible
-- Works in nearly every UI-Framework. Check [here](https://agile-ts.org/docs/frameworks) if your preferred framework is supported too.
-- Surly behaves with the workflow that suits you best.
- No need for _reducers_, _actions_, ..
+- Works in nearly any UI-Framework. Check [here](https://agile-ts.org/docs/frameworks) if your preferred Framework is supported too.
+- Surly behaves with the workflow which suits you best. No need for _reducers_, _actions_, ..
- Has **no** external dependencies
### π― Easy to Use
@@ -115,14 +113,14 @@ or if you are no fan of following any tutorial, checkout your [examples](../exam
-To properly use AgileTs, in a UI-Framework we need **two** packages.
+To properly use AgileTs, in a UI-Framework we need to install **two** packages.
- The _Core Package_, which acts as the brain of AgileTs and manages all our States
```
npm install @agile-ts/core
```
-- and a _fitting Integration_ for our preferd UI-Framework.. in my case the [React Integration](https://www.npmjs.com/package/@agile-ts/react).
+- and a _fitting Integration_ for our preferd UI-Framework. In my case the [React Integration](https://www.npmjs.com/package/@agile-ts/react).
Check [here](https://agile-ts.org/docs/installation) if your desired Framework is supported, too.
```
npm install @agile-ts/react
@@ -138,7 +136,7 @@ To properly use AgileTs, in a UI-Framework we need **two** packages.
If AgileTs sounds interesting to you.
Checkout our **[docs](https://agile-ts.org/docs/)**.
And I am sure you will be able to use it in no time.
-In case you have any questions don't mind joining our [Discord Community](https://discord.gg/FTqeMNCxw7).
+In case you have any further questions don't mind joining our [Community Discord](https://discord.gg/FTqeMNCxw7).
@@ -147,9 +145,8 @@ In case you have any questions don't mind joining our [Discord Community](https:
-Get a part of AgileTs and start contributing.
+Get a part of AgileTs and start contributing. We welcome any meaningful contribution π
To find out more checkout the [CONTRIBUTING.md](https://github.com/agile-ts/agile/blob/master/CONTRIBUTING.md).
-We welcome any meaningful contribution π
@@ -176,5 +173,5 @@ We welcome any meaningful contribution π
-AgileTs is inspired by MVVM frameworks like [MobX](https://mobx.js.org/README.html) and [PulseJs](https://github.com/pulse-framework/pulse).
+AgileTs is inspired by [MVVM Frameworks](https://de.wikipedia.org/wiki/Model_View_ViewModel) like [MobX](https://mobx.js.org/README.html) and [PulseJs](https://github.com/pulse-framework/pulse).
From 38901435bef68481d53a6eabfedd1610c563f881 Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Fri, 12 Mar 2021 15:57:17 +0100
Subject: [PATCH 04/35] added set option in update method
---
packages/core/src/collection/index.ts | 32 +++++++++++++------
.../tests/unit/collection/collection.test.ts | 2 +-
2 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/packages/core/src/collection/index.ts b/packages/core/src/collection/index.ts
index b4d8bf32..12d7f9e7 100644
--- a/packages/core/src/collection/index.ts
+++ b/packages/core/src/collection/index.ts
@@ -122,7 +122,7 @@ export class Collection {
*/
public Group(
initialItems?: Array,
- config?: GroupConfigInterface
+ config: GroupConfigInterface = {}
): Group {
if (this.isInstantiated) {
const key = config?.key || generateId();
@@ -150,7 +150,7 @@ export class Collection {
*/
public Selector(
initialKey: ItemKey,
- config?: SelectorConfigInterface
+ config: SelectorConfigInterface = {}
): Selector {
if (this.isInstantiated) {
const key = config?.key || generateId();
@@ -305,7 +305,7 @@ export class Collection {
const item = this.getItem(itemKey, { notExisting: true });
const primaryKey = this.config.primaryKey;
config = defineConfig(config, {
- addNewProperties: true,
+ patch: true,
background: false,
});
@@ -335,11 +335,23 @@ export class Collection {
background: config.background,
});
- // Apply changes to Item
- item.patch(changes as any, {
- background: config.background,
- addNewProperties: config.addNewProperties,
- });
+ if (config.patch) {
+ let patchConfig: { addNewProperties?: boolean } =
+ typeof config.patch === 'object' ? config.patch : {};
+ patchConfig = defineConfig(patchConfig, {
+ addNewProperties: true,
+ });
+
+ // Apply changes to Item
+ item.patch(changes as any, {
+ background: config.background,
+ addNewProperties: patchConfig.addNewProperties,
+ });
+ } else {
+ item.set(changes as any, {
+ background: config.background,
+ });
+ }
return item;
}
@@ -1205,11 +1217,11 @@ export interface CollectConfigInterface {
}
/**
- * @param addNewProperties - If properties that doesn't exist in base ItemData get added
+ * @param patch - If Data gets merged into the current Data
* @param background - If updating an Item happens in the background (-> not causing any rerender)
*/
export interface UpdateConfigInterface {
- addNewProperties?: boolean;
+ patch?: boolean | { addNewProperties?: boolean };
background?: boolean;
}
diff --git a/packages/core/tests/unit/collection/collection.test.ts b/packages/core/tests/unit/collection/collection.test.ts
index 22cefdfc..4a5fd1e7 100644
--- a/packages/core/tests/unit/collection/collection.test.ts
+++ b/packages/core/tests/unit/collection/collection.test.ts
@@ -732,7 +732,7 @@ describe('Collection Tests', () => {
'dummyItem',
{ name: 'hans' },
{
- addNewProperties: true,
+ patch: true,
background: true,
}
);
From 190589cdbeebf4244945829288dcd0b6087c8296 Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Fri, 12 Mar 2021 20:06:18 +0100
Subject: [PATCH 05/35] return this in reset method
---
packages/core/src/collection/index.ts | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/packages/core/src/collection/index.ts b/packages/core/src/collection/index.ts
index 12d7f9e7..e4dc2074 100644
--- a/packages/core/src/collection/index.ts
+++ b/packages/core/src/collection/index.ts
@@ -859,7 +859,7 @@ export class Collection {
* @public
* Resets this Collection
*/
- public reset() {
+ public reset(): this {
// Reset Data
this.data = {};
this.size = 0;
@@ -869,6 +869,8 @@ export class Collection {
// Reset Selectors
for (const key in this.selectors) this.getSelector(key)?.reset();
+
+ return this;
}
//=========================================================================================================
From b115409462e879ebb6870d1aeda9788969c08e52 Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Sat, 13 Mar 2021 15:18:54 +0100
Subject: [PATCH 06/35] fixed state tests
---
packages/core/src/collection/index.ts | 4 +-
packages/core/src/state/index.ts | 42 +++++++++---
packages/core/src/state/state.observer.ts | 4 +-
.../core/tests/unit/collection/group.test.ts | 9 ++-
.../core/tests/unit/collection/item.test.ts | 6 +-
.../tests/unit/collection/selector.test.ts | 9 ++-
.../core/tests/unit/computed/computed.test.ts | 6 +-
.../tests/unit/state/state.observer.test.ts | 2 +-
packages/core/tests/unit/state/state.test.ts | 68 +++++++++++++++----
9 files changed, 116 insertions(+), 34 deletions(-)
diff --git a/packages/core/src/collection/index.ts b/packages/core/src/collection/index.ts
index e4dc2074..4cd53d2b 100644
--- a/packages/core/src/collection/index.ts
+++ b/packages/core/src/collection/index.ts
@@ -887,7 +887,7 @@ export class Collection {
itemKeys: ItemKey | Array,
groupKeys: GroupKey | Array,
config: GroupAddConfig = {}
- ) {
+ ): this {
const _itemKeys = normalizeArray(itemKeys);
const _groupKeys = normalizeArray(groupKeys);
@@ -895,6 +895,8 @@ export class Collection {
_groupKeys.forEach((groupKey) => {
this.getGroup(groupKey)?.add(_itemKeys, config);
});
+
+ return this;
}
//=========================================================================================================
diff --git a/packages/core/src/state/index.ts b/packages/core/src/state/index.ts
index 83268e40..55f9bc32 100644
--- a/packages/core/src/state/index.ts
+++ b/packages/core/src/state/index.ts
@@ -15,7 +15,6 @@ import {
PersistentKey,
ComputedTracker,
StateIngestConfigInterface,
- StateRuntimeJobConfigInterface,
} from '../internal';
export class State {
@@ -34,7 +33,8 @@ export class State {
public sideEffects: {
[key: string]: SideEffectInterface>;
} = {}; // SideEffects of State (will be executed in Runtime)
- public computeMethod?: ComputeMethod;
+ public computeValueMethod?: ComputeValueMethod;
+ public computeExistsMethod: ComputeExistsMethod;
public isPersisted = false; // If State can be stored in Agile Storage (-> successfully integrated persistent)
public persistent: StatePersistent | undefined; // Manages storing State Value into Storage
@@ -68,6 +68,9 @@ export class State {
this.previousStateValue = copy(initialValue);
this.nextStateValue = copy(initialValue);
this.isPlaceholder = true;
+ this.computeExistsMethod = (v) => {
+ return v != null;
+ };
// Initial Set
if (!config.isPlaceholder) this.set(initialValue, { overwrite: true });
@@ -476,7 +479,25 @@ export class State {
* Checks if State exists
*/
public get exists(): boolean {
- return !this.isPlaceholder;
+ return !this.isPlaceholder && this.computeExistsMethod(this.value);
+ }
+
+ //=========================================================================================================
+ // Compute Exists
+ //=========================================================================================================
+ /**
+ * @public
+ * Function that computes the exists status of the State
+ * @param method - Computed Function
+ */
+ public computeExists(method: ComputeExistsMethod): this {
+ if (!isFunction(method)) {
+ Agile.logger.error(`A 'computeExistsMethod' has to be a function!`);
+ return this;
+ }
+ this.computeExistsMethod = method;
+
+ return this;
}
//=========================================================================================================
@@ -521,19 +542,23 @@ export class State {
}
//=========================================================================================================
- // Compute
+ // Compute Value
//=========================================================================================================
/**
* @public
* Function that recomputes State Value if it changes
* @param method - Computed Function
*/
- public compute(method: ComputeMethod): this {
+ public computeValue(method: ComputeValueMethod): this {
if (!isFunction(method)) {
- Agile.logger.error('A computeMethod has to be a function!');
+ Agile.logger.error(`A 'computeValueMethod' has to be a function!`);
return this;
}
- this.computeMethod = method;
+ this.computeValueMethod = method;
+
+ // Initial compute
+ this.set(method(this.nextStateValue));
+
return this;
}
@@ -662,7 +687,8 @@ export interface StatePersistentConfigInterface {
}
export type StateWatcherCallback = (value: T, key: string) => void;
-export type ComputeMethod = (value: T) => T;
+export type ComputeValueMethod = (value: T) => T;
+export type ComputeExistsMethod = (value: T) => boolean;
export type SideEffectFunctionType> = (
instance: Instance,
diff --git a/packages/core/src/state/state.observer.ts b/packages/core/src/state/state.observer.ts
index 1c168454..cc33e88c 100644
--- a/packages/core/src/state/state.observer.ts
+++ b/packages/core/src/state/state.observer.ts
@@ -86,8 +86,8 @@ export class StateObserver extends Observer {
}
// Assign next State Value and compute it if necessary
- this.nextStateValue = state.computeMethod
- ? copy(state.computeMethod(newStateValue))
+ this.nextStateValue = state.computeValueMethod
+ ? copy(state.computeValueMethod(newStateValue))
: copy(newStateValue);
// Check if State Value and new/next Value are equals
diff --git a/packages/core/tests/unit/collection/group.test.ts b/packages/core/tests/unit/collection/group.test.ts
index dff4258b..689f0ad2 100644
--- a/packages/core/tests/unit/collection/group.test.ts
+++ b/packages/core/tests/unit/collection/group.test.ts
@@ -56,7 +56,8 @@ describe('Group Tests', () => {
expect(group.observer.dependents.size).toBe(0);
expect(group.observer._key).toBeUndefined();
expect(group.sideEffects).toStrictEqual({});
- expect(group.computeMethod).toBeUndefined();
+ expect(group.computeValueMethod).toBeUndefined();
+ expect(group.computeExistsMethod).toBeInstanceOf(Function);
expect(group.isPersisted).toBeFalsy();
expect(group.persistent).toBeUndefined();
expect(group.watchers).toStrictEqual({});
@@ -89,7 +90,8 @@ describe('Group Tests', () => {
expect(group.observer.dependents.size).toBe(0);
expect(group.observer._key).toBe('dummyKey');
expect(group.sideEffects).toStrictEqual({});
- expect(group.computeMethod).toBeUndefined();
+ expect(group.computeValueMethod).toBeUndefined();
+ expect(group.computeExistsMethod).toBeInstanceOf(Function);
expect(group.isPersisted).toBeFalsy();
expect(group.persistent).toBeUndefined();
expect(group.watchers).toStrictEqual({});
@@ -119,7 +121,8 @@ describe('Group Tests', () => {
expect(group.observer.dependents.size).toBe(0);
expect(group.observer._key).toBeUndefined();
expect(group.sideEffects).toStrictEqual({});
- expect(group.computeMethod).toBeUndefined();
+ expect(group.computeValueMethod).toBeUndefined();
+ expect(group.computeExistsMethod).toBeInstanceOf(Function);
expect(group.isPersisted).toBeFalsy();
expect(group.persistent).toBeUndefined();
expect(group.watchers).toStrictEqual({});
diff --git a/packages/core/tests/unit/collection/item.test.ts b/packages/core/tests/unit/collection/item.test.ts
index 5e82d9f2..1b99a39c 100644
--- a/packages/core/tests/unit/collection/item.test.ts
+++ b/packages/core/tests/unit/collection/item.test.ts
@@ -41,7 +41,8 @@ describe('Item Tests', () => {
dummyData[dummyCollection.config.primaryKey]
);
expect(item.sideEffects).toStrictEqual({});
- expect(item.computeMethod).toBeUndefined();
+ expect(item.computeValueMethod).toBeUndefined();
+ expect(item.computeExistsMethod).toBeInstanceOf(Function);
expect(item.isPersisted).toBeFalsy();
expect(item.persistent).toBeUndefined();
expect(item.watchers).toStrictEqual({});
@@ -78,7 +79,8 @@ describe('Item Tests', () => {
dummyData[dummyCollection.config.primaryKey]
);
expect(item.sideEffects).toStrictEqual({});
- expect(item.computeMethod).toBeUndefined();
+ expect(item.computeValueMethod).toBeUndefined();
+ expect(item.computeExistsMethod).toBeInstanceOf(Function);
expect(item.isPersisted).toBeFalsy();
expect(item.persistent).toBeUndefined();
expect(item.watchers).toStrictEqual({});
diff --git a/packages/core/tests/unit/collection/selector.test.ts b/packages/core/tests/unit/collection/selector.test.ts
index 27673b59..7b583406 100644
--- a/packages/core/tests/unit/collection/selector.test.ts
+++ b/packages/core/tests/unit/collection/selector.test.ts
@@ -43,7 +43,8 @@ describe('Selector Tests', () => {
expect(selector.observer.dependents.size).toBe(0);
expect(selector.observer._key).toBeUndefined();
expect(selector.sideEffects).toStrictEqual({});
- expect(selector.computeMethod).toBeUndefined();
+ expect(selector.computeValueMethod).toBeUndefined();
+ expect(selector.computeExistsMethod).toBeInstanceOf(Function);
expect(selector.isPersisted).toBeFalsy();
expect(selector.persistent).toBeUndefined();
expect(selector.watchers).toStrictEqual({});
@@ -76,7 +77,8 @@ describe('Selector Tests', () => {
expect(selector.observer.dependents.size).toBe(0);
expect(selector.observer._key).toBe('dummyKey');
expect(selector.sideEffects).toStrictEqual({});
- expect(selector.computeMethod).toBeUndefined();
+ expect(selector.computeValueMethod).toBeUndefined();
+ expect(selector.computeExistsMethod).toBeInstanceOf(Function);
expect(selector.isPersisted).toBeFalsy();
expect(selector.persistent).toBeUndefined();
expect(selector.watchers).toStrictEqual({});
@@ -107,7 +109,8 @@ describe('Selector Tests', () => {
expect(selector.observer.dependents.size).toBe(0);
expect(selector.observer._key).toBeUndefined();
expect(selector.sideEffects).toStrictEqual({});
- expect(selector.computeMethod).toBeUndefined();
+ expect(selector.computeValueMethod).toBeUndefined();
+ expect(computed.computeExistsMethod).toBeInstanceOf(Function);
expect(selector.isPersisted).toBeFalsy();
expect(selector.persistent).toBeUndefined();
expect(selector.watchers).toStrictEqual({});
diff --git a/packages/core/tests/unit/computed/computed.test.ts b/packages/core/tests/unit/computed/computed.test.ts
index e6cee1f8..c82f50c3 100644
--- a/packages/core/tests/unit/computed/computed.test.ts
+++ b/packages/core/tests/unit/computed/computed.test.ts
@@ -37,7 +37,8 @@ describe('Computed Tests', () => {
expect(computed.observer.dependents.size).toBe(0);
expect(computed.observer._key).toBeUndefined();
expect(computed.sideEffects).toStrictEqual({});
- expect(computed.computeMethod).toBeUndefined();
+ expect(computed.computeValueMethod).toBeUndefined();
+ expect(computed.computeExistsMethod).toBeInstanceOf(Function);
expect(computed.isPersisted).toBeFalsy();
expect(computed.persistent).toBeUndefined();
expect(computed.watchers).toStrictEqual({});
@@ -78,7 +79,8 @@ describe('Computed Tests', () => {
expect(computed.observer.dependents.has(dummyObserver1)).toBeTruthy(); // x
expect(computed.observer._key).toBe('coolComputed'); // x
expect(computed.sideEffects).toStrictEqual({});
- expect(computed.computeMethod).toBeUndefined();
+ expect(computed.computeValueMethod).toBeUndefined();
+ expect(computed.computeExistsMethod).toBeInstanceOf(Function);
expect(computed.isPersisted).toBeFalsy();
expect(computed.persistent).toBeUndefined();
expect(computed.watchers).toStrictEqual({});
diff --git a/packages/core/tests/unit/state/state.observer.test.ts b/packages/core/tests/unit/state/state.observer.test.ts
index ce2a081c..7b95ac5d 100644
--- a/packages/core/tests/unit/state/state.observer.test.ts
+++ b/packages/core/tests/unit/state/state.observer.test.ts
@@ -265,7 +265,7 @@ describe('StateObserver Tests', () => {
});
it('should ingest State into Runtime and compute newStateValue if State compute Function is set (default config)', () => {
- dummyState.computeMethod = (value) => `cool value '${value}'`;
+ dummyState.computeValueMethod = (value) => `cool value '${value}'`;
stateObserver.ingestValue('updatedDummyValue');
diff --git a/packages/core/tests/unit/state/state.test.ts b/packages/core/tests/unit/state/state.test.ts
index da41eff3..58731002 100644
--- a/packages/core/tests/unit/state/state.test.ts
+++ b/packages/core/tests/unit/state/state.test.ts
@@ -42,7 +42,8 @@ describe('State Tests', () => {
expect(state.observer.dependents.size).toBe(0);
expect(state.observer._key).toBeUndefined();
expect(state.sideEffects).toStrictEqual({});
- expect(state.computeMethod).toBeUndefined();
+ expect(state.computeValueMethod).toBeUndefined();
+ expect(state.computeExistsMethod).toBeInstanceOf(Function);
expect(state.isPersisted).toBeFalsy();
expect(state.persistent).toBeUndefined();
expect(state.watchers).toStrictEqual({});
@@ -73,7 +74,8 @@ describe('State Tests', () => {
expect(state.observer.dependents.has(dummyObserver)).toBeTruthy();
expect(state.observer._key).toBe('coolState');
expect(state.sideEffects).toStrictEqual({});
- expect(state.computeMethod).toBeUndefined();
+ expect(state.computeValueMethod).toBeUndefined();
+ expect(state.computeExistsMethod).toBeInstanceOf(Function);
expect(state.isPersisted).toBeFalsy();
expect(state.persistent).toBeUndefined();
expect(state.watchers).toStrictEqual({});
@@ -98,7 +100,8 @@ describe('State Tests', () => {
expect(state.observer.dependents.size).toBe(0);
expect(state.observer._key).toBeUndefined();
expect(state.sideEffects).toStrictEqual({});
- expect(state.computeMethod).toBeUndefined();
+ expect(state.computeValueMethod).toBeUndefined();
+ expect(state.computeExistsMethod).toBeInstanceOf(Function);
expect(state.isPersisted).toBeFalsy();
expect(state.persistent).toBeUndefined();
expect(state.watchers).toStrictEqual({});
@@ -739,16 +742,51 @@ describe('State Tests', () => {
});
describe('exists get function tests', () => {
- it('should return true if State is no placeholder', () => {
+ it('should return true if State is no placeholder and computeExistsMethod returns true', () => {
+ numberState.computeExistsMethod = jest.fn().mockReturnValueOnce(true);
numberState.isPlaceholder = false;
expect(numberState.exists).toBeTruthy();
+ expect(numberState.computeExistsMethod).toHaveBeenCalledWith(
+ numberState.value
+ );
+ });
+
+ it('should return false if State is no placeholder and computeExistsMethod returns false', () => {
+ numberState.computeExistsMethod = jest.fn().mockReturnValueOnce(false);
+ numberState.isPlaceholder = false;
+
+ expect(numberState.exists).toBeFalsy();
+ expect(numberState.computeExistsMethod).toHaveBeenCalledWith(
+ numberState.value
+ );
});
it('should return false if State is placeholder"', () => {
+ numberState.computeExistsMethod = jest.fn(() => true);
numberState.isPlaceholder = true;
expect(numberState.exists).toBeFalsy();
+ expect(numberState.computeExistsMethod).not.toHaveBeenCalled(); // since isPlaceholder gets checked first
+ });
+ });
+
+ describe('computeExists function tests', () => {
+ it('should assign passed function to computeExistsMethod', () => {
+ const computeMethod = (value) => value === null;
+
+ numberState.computeExists(computeMethod);
+
+ expect(numberState.computeExistsMethod).toBe(computeMethod);
+ });
+
+ it("shouldn't assign passed invalid function to computeExistsMethod", () => {
+ numberState.computeExists(10 as any);
+
+ expect(numberState.computeExistsMethod).toBeInstanceOf(Function);
+ expect(console.error).toHaveBeenCalledWith(
+ "Agile Error: A 'computeExistsMethod' has to be a function!"
+ );
});
});
@@ -814,21 +852,27 @@ describe('State Tests', () => {
});
});
- describe('compute function tests', () => {
- it('should assign passed function to computeMethod', () => {
+ describe('computeValue function tests', () => {
+ beforeEach(() => {
+ numberState.set = jest.fn();
+ });
+
+ it('should assign passed function to computeValueMethod and compute State value initially', () => {
const computeMethod = () => 10;
- numberState.compute(computeMethod);
+ numberState.computeValue(computeMethod);
- expect(numberState.computeMethod).toBe(computeMethod);
+ expect(numberState.set).toHaveBeenCalledWith(10);
+ expect(numberState.computeValueMethod).toBe(computeMethod);
});
- it("shouldn't assign passed invalid function to computeMethod", () => {
- numberState.compute(10 as any);
+ it("shouldn't assign passed invalid function to computeValueMethod", () => {
+ numberState.computeValue(10 as any);
- expect(numberState.computeMethod).toBeUndefined();
+ expect(numberState.set).not.toHaveBeenCalled();
+ expect(numberState.computeValueMethod).toBeUndefined();
expect(console.error).toHaveBeenCalledWith(
- 'Agile Error: A computeMethod has to be a function!'
+ "Agile Error: A 'computeValueMethod' has to be a function!"
);
});
});
From db2252a9ecaddd4b453c26682a207d06c7419f16 Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Sat, 13 Mar 2021 15:19:18 +0100
Subject: [PATCH 07/35] fixed typo
---
packages/core/tests/unit/collection/selector.test.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/core/tests/unit/collection/selector.test.ts b/packages/core/tests/unit/collection/selector.test.ts
index 7b583406..d318d30f 100644
--- a/packages/core/tests/unit/collection/selector.test.ts
+++ b/packages/core/tests/unit/collection/selector.test.ts
@@ -110,7 +110,7 @@ describe('Selector Tests', () => {
expect(selector.observer._key).toBeUndefined();
expect(selector.sideEffects).toStrictEqual({});
expect(selector.computeValueMethod).toBeUndefined();
- expect(computed.computeExistsMethod).toBeInstanceOf(Function);
+ expect(selector.computeExistsMethod).toBeInstanceOf(Function);
expect(selector.isPersisted).toBeFalsy();
expect(selector.persistent).toBeUndefined();
expect(selector.watchers).toStrictEqual({});
From 97f22ae973ce4104168fc165c00869ac509c1d04 Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Sat, 13 Mar 2021 16:11:51 +0100
Subject: [PATCH 08/35] optimized update function tests
---
packages/core/src/collection/index.ts | 21 ++++-
.../tests/unit/collection/collection.test.ts | 80 ++++++++++++++++++-
2 files changed, 93 insertions(+), 8 deletions(-)
diff --git a/packages/core/src/collection/index.ts b/packages/core/src/collection/index.ts
index 4cd53d2b..2923ffdd 100644
--- a/packages/core/src/collection/index.ts
+++ b/packages/core/src/collection/index.ts
@@ -326,16 +326,17 @@ export class Collection {
const newItemKey = changes[primaryKey] || oldItemKey;
const updateItemKey = oldItemKey !== newItemKey;
- // Delete primaryKey from 'changes' because if it has changed, it gets properly updated in 'updateItemKey' (below)
- if (changes[primaryKey]) delete changes[primaryKey];
-
// Update ItemKey
if (updateItemKey)
this.updateItemKey(oldItemKey, newItemKey, {
background: config.background,
});
+ // Patch changes into Item
if (config.patch) {
+ // Delete primaryKey from 'changes' because if it has changed, it gets properly updated in 'updateItemKey' (see above)
+ if (changes[primaryKey]) delete changes[primaryKey];
+
let patchConfig: { addNewProperties?: boolean } =
typeof config.patch === 'object' ? config.patch : {};
patchConfig = defineConfig(patchConfig, {
@@ -347,7 +348,19 @@ export class Collection {
background: config.background,
addNewProperties: patchConfig.addNewProperties,
});
- } else {
+ }
+
+ // Set changes into Item
+ if (!config.patch) {
+ // To make sure that the primaryKey doesn't differ from the changes object primaryKey
+ if (changes[this.config.primaryKey] !== itemKey) {
+ changes[this.config.primaryKey] = itemKey;
+ Agile.logger.warn(
+ `By overwriting the whole Item don't forget passing the correct primaryKey!`, changes
+ );
+ }
+
+ // Apply changes to Item
item.set(changes as any, {
background: config.background,
});
diff --git a/packages/core/tests/unit/collection/collection.test.ts b/packages/core/tests/unit/collection/collection.test.ts
index 4a5fd1e7..9d71b274 100644
--- a/packages/core/tests/unit/collection/collection.test.ts
+++ b/packages/core/tests/unit/collection/collection.test.ts
@@ -707,14 +707,16 @@ describe('Collection Tests', () => {
};
dummyItem.patch = jest.fn();
+ dummyItem.set = jest.fn();
collection.updateItemKey = jest.fn();
});
- it('should update existing Item with valid changes Object (default config)', () => {
+ it('should update existing Item by patching valid changes Object (default config)', () => {
const response = collection.update('dummyItem', { name: 'hans' });
expect(response).toBe(dummyItem);
expect(console.error).not.toHaveBeenCalled();
+ expect(console.warn).not.toHaveBeenCalled();
expect(dummyItem.patch).toHaveBeenCalledWith(
{
name: 'hans',
@@ -724,21 +726,22 @@ describe('Collection Tests', () => {
addNewProperties: true,
}
);
+ expect(dummyItem.set).not.toHaveBeenCalled();
expect(collection.updateItemKey).not.toHaveBeenCalled();
});
- it('should update existing Item with valid changes Object (specific config)', () => {
+ it('should update existing Item by patching valid changes Object (specific config)', () => {
const response = collection.update(
'dummyItem',
{ name: 'hans' },
{
- patch: true,
background: true,
}
);
expect(response).toBe(dummyItem);
expect(console.error).not.toHaveBeenCalled();
+ expect(console.warn).not.toHaveBeenCalled();
expect(dummyItem.patch).toHaveBeenCalledWith(
{
name: 'hans',
@@ -748,16 +751,18 @@ describe('Collection Tests', () => {
addNewProperties: true,
}
);
+ expect(dummyItem.set).not.toHaveBeenCalled();
expect(collection.updateItemKey).not.toHaveBeenCalled();
});
- it('should update existing placeholder Item with valid changes Object (default config)', () => {
+ it('should update existing placeholder Item by patching valid changes Object (default config)', () => {
dummyItem.isPlaceholder = true;
const response = collection.update('dummyItem', { name: 'hans' });
expect(response).toBe(dummyItem);
expect(console.error).not.toHaveBeenCalled();
+ expect(console.warn).not.toHaveBeenCalled();
expect(dummyItem.patch).toHaveBeenCalledWith(
{
name: 'hans',
@@ -767,6 +772,67 @@ describe('Collection Tests', () => {
addNewProperties: true,
}
);
+ expect(dummyItem.set).not.toHaveBeenCalled();
+ expect(collection.updateItemKey).not.toHaveBeenCalled();
+ });
+
+ it('should update existing Item by setting valid changes Object (default config)', () => {
+ const response = collection.update(
+ 'dummyItem',
+ { id: 'dummyItem', name: 'hans' },
+ { patch: false }
+ );
+
+ expect(response).toBe(dummyItem);
+ expect(console.error).not.toHaveBeenCalled();
+ expect(console.warn).not.toHaveBeenCalled();
+ expect(dummyItem.patch).not.toHaveBeenCalled();
+ expect(dummyItem.set).toHaveBeenCalledWith(
+ { id: 'dummyItem', name: 'hans' },
+ { background: false }
+ );
+ expect(collection.updateItemKey).not.toHaveBeenCalled();
+ });
+
+ it('should update existing Item by setting valid changes Object (specific config)', () => {
+ const response = collection.update(
+ 'dummyItem',
+ { id: 'dummyItem', name: 'hans' },
+ {
+ patch: false,
+ background: true,
+ }
+ );
+
+ expect(response).toBe(dummyItem);
+ expect(console.error).not.toHaveBeenCalled();
+ expect(console.warn).not.toHaveBeenCalled();
+ expect(dummyItem.patch).not.toHaveBeenCalled();
+ expect(dummyItem.set).toHaveBeenCalledWith(
+ { id: 'dummyItem', name: 'hans' },
+ { background: true }
+ );
+ expect(collection.updateItemKey).not.toHaveBeenCalled();
+ });
+
+ it('should update existing Item by setting valid changes Object without primaryKey and should print warning (default config)', () => {
+ const response = collection.update(
+ 'dummyItem',
+ { name: 'hans' },
+ { patch: false }
+ );
+
+ expect(response).toBe(dummyItem);
+ expect(console.error).not.toHaveBeenCalled();
+ expect(console.warn).toHaveBeenCalledWith(
+ "Agile Warn: By overwriting the Item don't forget passing the primaryKey!"
+ , {id: 'dummyItem', name: 'hans'}
+ );
+ expect(dummyItem.patch).not.toHaveBeenCalled();
+ expect(dummyItem.set).toHaveBeenCalledWith(
+ { id: 'dummyItem', name: 'hans' },
+ { background: false }
+ );
expect(collection.updateItemKey).not.toHaveBeenCalled();
});
@@ -777,7 +843,9 @@ describe('Collection Tests', () => {
expect(console.error).toHaveBeenCalledWith(
`Agile Error: Item with key/name 'notExisting' doesn't exist in Collection '${collection._key}'!`
);
+ expect(console.warn).not.toHaveBeenCalled();
expect(dummyItem.patch).not.toHaveBeenCalled();
+ expect(dummyItem.set).not.toHaveBeenCalled();
expect(collection.updateItemKey).not.toHaveBeenCalled();
});
@@ -791,7 +859,9 @@ describe('Collection Tests', () => {
expect(console.error).toHaveBeenCalledWith(
`Agile Error: You have to pass an valid Changes Object to update 'dummyItem' in '${collection._key}'!`
);
+ expect(console.warn).not.toHaveBeenCalled();
expect(dummyItem.patch).not.toHaveBeenCalled();
+ expect(dummyItem.set).not.toHaveBeenCalled();
expect(collection.updateItemKey).not.toHaveBeenCalled();
});
@@ -803,6 +873,7 @@ describe('Collection Tests', () => {
expect(response).toBe(dummyItem);
expect(console.error).not.toHaveBeenCalled();
+ expect(console.warn).not.toHaveBeenCalled();
expect(dummyItem.patch).toHaveBeenCalledWith(
{
name: 'hans',
@@ -812,6 +883,7 @@ describe('Collection Tests', () => {
addNewProperties: true,
}
);
+ expect(dummyItem.set).not.toHaveBeenCalled();
expect(collection.updateItemKey).toHaveBeenCalledWith(
'dummyItem',
'newDummyItemKey',
From cfd9a0f2e7d4ff10f86f522c9bf7cbbadc4ae063 Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Sat, 13 Mar 2021 17:22:27 +0100
Subject: [PATCH 09/35] fixed compute issue
---
packages/core/src/computed/index.ts | 6 +++---
packages/core/src/state/state.observer.ts | 2 +-
packages/core/tests/unit/computed/computed.test.ts | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/packages/core/src/computed/index.ts b/packages/core/src/computed/index.ts
index 707b761f..55d9f6b4 100644
--- a/packages/core/src/computed/index.ts
+++ b/packages/core/src/computed/index.ts
@@ -109,13 +109,13 @@ export class Computed extends State<
}
//=========================================================================================================
- // Compute Values
+ // Compute
//=========================================================================================================
/**
* @internal
- * Computes Value and adds missing Dependencies to Computed
+ * Recomputes value and adds missing dependencies to Computed
*/
- public computeValue(): ComputedValueType {
+ public compute(): ComputedValueType {
// Auto track Observers the computeFunction might depend on
ComputedTracker.track();
const computedValue = this.computeFunction();
diff --git a/packages/core/src/state/state.observer.ts b/packages/core/src/state/state.observer.ts
index cc33e88c..52bb5301 100644
--- a/packages/core/src/state/state.observer.ts
+++ b/packages/core/src/state/state.observer.ts
@@ -47,7 +47,7 @@ export class StateObserver extends Observer {
const state = this.state();
let newStateValue: ValueType;
- if (state instanceof Computed) newStateValue = state.computeValue();
+ if (state instanceof Computed) newStateValue = state.compute();
else newStateValue = state.nextStateValue;
this.ingestValue(newStateValue, config);
diff --git a/packages/core/tests/unit/computed/computed.test.ts b/packages/core/tests/unit/computed/computed.test.ts
index c82f50c3..1cb5eb62 100644
--- a/packages/core/tests/unit/computed/computed.test.ts
+++ b/packages/core/tests/unit/computed/computed.test.ts
@@ -217,7 +217,7 @@ describe('Computed Tests', () => {
});
});
- describe('computeValue function tests', () => {
+ describe('compute function tests', () => {
let dummyObserver1: Observer;
let dummyObserver2: Observer;
let dummyObserver3: Observer;
@@ -242,7 +242,7 @@ describe('Computed Tests', () => {
dummyObserver2,
]);
- const response = computed.computeValue();
+ const response = computed.compute();
expect(response).toBe('newComputedValue');
expect(dummyComputeFunction).toHaveBeenCalled();
From 983782609f584753ec693d5c2dac9b49e7770fdd Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Sat, 13 Mar 2021 17:28:56 +0100
Subject: [PATCH 10/35] fixed typo
---
packages/multieditor/src/multieditor.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/multieditor/src/multieditor.ts b/packages/multieditor/src/multieditor.ts
index 15c69268..77404c50 100644
--- a/packages/multieditor/src/multieditor.ts
+++ b/packages/multieditor/src/multieditor.ts
@@ -85,7 +85,7 @@ export class MultiEditor<
item.validate();
if (Object.prototype.hasOwnProperty.call(this.computeMethods, key)) {
const computeMethod = this.computeMethods[key];
- item.compute(computeMethod);
+ item.computeValue(computeMethod);
}
}
}
From a52620beaf9e130657526862bd65ee831e4607c0 Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Sat, 13 Mar 2021 17:29:48 +0100
Subject: [PATCH 11/35] fixed typo again
---
packages/multieditor/src/multieditor.ts | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/packages/multieditor/src/multieditor.ts b/packages/multieditor/src/multieditor.ts
index 77404c50..573ca0ce 100644
--- a/packages/multieditor/src/multieditor.ts
+++ b/packages/multieditor/src/multieditor.ts
@@ -1,6 +1,6 @@
import {
Agile,
- ComputeMethod,
+ ComputeValueMethod,
copy,
defineConfig,
getAgileInstance,
@@ -30,7 +30,7 @@ export class MultiEditor<
public validateMethods: DataObject<
ValidationMethodInterface | Validator
> = {};
- public computeMethods: DataObject> = {};
+ public computeMethods: DataObject> = {};
public onSubmit: (
preparedData: DataObject,
config?: OnSubmitConfigType
@@ -514,7 +514,7 @@ export interface CreateEditorConfigInterface<
validateMethods?: DataObject<
ValidationMethodInterface | Validator
>;
- computeMethods?: DataObject>;
+ computeMethods?: DataObject>;
onSubmit: (
preparedData: DataObject,
config?: onSubmitConfig
From fe697219327d6dacd19e4ed802eb224424681662 Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Sat, 13 Mar 2021 17:41:43 +0100
Subject: [PATCH 12/35] fixed tests
---
packages/core/tests/unit/collection/collection.test.ts | 8 +++++---
packages/core/tests/unit/state/state.observer.test.ts | 4 ++--
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/packages/core/tests/unit/collection/collection.test.ts b/packages/core/tests/unit/collection/collection.test.ts
index 9d71b274..46bade21 100644
--- a/packages/core/tests/unit/collection/collection.test.ts
+++ b/packages/core/tests/unit/collection/collection.test.ts
@@ -824,9 +824,11 @@ describe('Collection Tests', () => {
expect(response).toBe(dummyItem);
expect(console.error).not.toHaveBeenCalled();
- expect(console.warn).toHaveBeenCalledWith(
- "Agile Warn: By overwriting the Item don't forget passing the primaryKey!"
- , {id: 'dummyItem', name: 'hans'}
+ expect(
+ console.warn
+ ).toHaveBeenCalledWith(
+ "Agile Warn: By overwriting the whole Item don't forget passing the correct primaryKey!",
+ { id: 'dummyItem', name: 'hans' }
);
expect(dummyItem.patch).not.toHaveBeenCalled();
expect(dummyItem.set).toHaveBeenCalledWith(
diff --git a/packages/core/tests/unit/state/state.observer.test.ts b/packages/core/tests/unit/state/state.observer.test.ts
index 7b95ac5d..ebfc1c09 100644
--- a/packages/core/tests/unit/state/state.observer.test.ts
+++ b/packages/core/tests/unit/state/state.observer.test.ts
@@ -121,7 +121,7 @@ describe('StateObserver Tests', () => {
});
it('should call ingestValue with computedValue if Observer belongs to a ComputedState (default config)', () => {
- dummyComputed.computeValue = jest.fn(() => 'computedValue');
+ dummyComputed.compute = jest.fn(() => 'computedValue');
computedObserver.ingest();
@@ -129,7 +129,7 @@ describe('StateObserver Tests', () => {
'computedValue',
{}
);
- expect(dummyComputed.computeValue).toHaveBeenCalled();
+ expect(dummyComputed.compute).toHaveBeenCalled();
});
});
From ac387b5e1336c1004cb380bc3cf39b78d4720953 Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Sun, 14 Mar 2021 11:30:52 +0100
Subject: [PATCH 13/35] fixed group add interface naming
---
packages/core/src/collection/group.ts | 10 +++++-----
packages/core/src/collection/index.ts | 4 ++--
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/packages/core/src/collection/group.ts b/packages/core/src/collection/group.ts
index 27ef35eb..11b1805c 100644
--- a/packages/core/src/collection/group.ts
+++ b/packages/core/src/collection/group.ts
@@ -114,7 +114,7 @@ export class Group extends State> {
*/
public remove(
itemKeys: ItemKey | ItemKey[],
- config: GroupRemoveConfig = {}
+ config: GroupRemoveConfigInterface = {}
): this {
const _itemKeys = normalizeArray(itemKeys);
const notExistingItemKeysInCollection: Array = [];
@@ -165,12 +165,12 @@ export class Group extends State> {
* @param itemKeys - ItemKey/s that get added to the Group
* @param config - Config
*/
- public add(itemKeys: ItemKey | ItemKey[], config: GroupAddConfig = {}): this {
+ public add(itemKeys: ItemKey | ItemKey[], config: GroupAddConfigInterface = {}): this {
const _itemKeys = normalizeArray(itemKeys);
const notExistingItemKeysInCollection: Array = [];
const existingItemKeys: Array = [];
let newGroupValue = copy(this.nextStateValue);
- config = defineConfig(config, {
+ config = defineConfig(config, {
method: 'push',
overwrite: false,
background: false,
@@ -335,7 +335,7 @@ export type GroupKey = string | number;
* @param overwrite - If adding ItemKey overwrites old ItemKey (-> otherwise it gets added to the end of the Group)
* @param background - If adding ItemKey happens in the background (-> not causing any rerender)
*/
-export interface GroupAddConfig {
+export interface GroupAddConfigInterface {
method?: 'unshift' | 'push';
overwrite?: boolean;
background?: boolean;
@@ -344,7 +344,7 @@ export interface GroupAddConfig {
/**
* @param background - If removing ItemKey happens in the background (-> not causing any rerender)
*/
-export interface GroupRemoveConfig {
+export interface GroupRemoveConfigInterface {
background?: boolean;
}
diff --git a/packages/core/src/collection/index.ts b/packages/core/src/collection/index.ts
index 2923ffdd..a96d118d 100644
--- a/packages/core/src/collection/index.ts
+++ b/packages/core/src/collection/index.ts
@@ -12,7 +12,7 @@ import {
normalizeArray,
copy,
CollectionPersistent,
- GroupAddConfig,
+ GroupAddConfigInterface,
ComputedTracker,
generateId,
SideEffectConfigInterface,
@@ -899,7 +899,7 @@ export class Collection {
public put(
itemKeys: ItemKey | Array,
groupKeys: GroupKey | Array,
- config: GroupAddConfig = {}
+ config: GroupAddConfigInterface = {}
): this {
const _itemKeys = normalizeArray(itemKeys);
const _groupKeys = normalizeArray(groupKeys);
From 01c9bc7b49cb7b60a4f14d335b7da69811db0c35 Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Sun, 14 Mar 2021 16:07:13 +0100
Subject: [PATCH 14/35] fixed 'Component.componentWillMount(): Assigning
directly to this.state is deprecated (except inside a component's
constructor). Use setState instead.' warning
---
packages/react/src/other/AgileHOC.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/react/src/other/AgileHOC.ts b/packages/react/src/other/AgileHOC.ts
index 855e464f..6a004b4b 100644
--- a/packages/react/src/other/AgileHOC.ts
+++ b/packages/react/src/other/AgileHOC.ts
@@ -122,7 +122,7 @@ const createHOC = (
this.agileProps = response.props;
// Merge depsWith Indicator into this.state
- this.state = flatMerge(this.state || {}, depsWithIndicator);
+ this.setState(flatMerge(this.state || {}, depsWithIndicator));
}
}
From f820970e0e115838c895c56a0765c10c520037d9 Mon Sep 17 00:00:00 2001
From: BennoDev <57860196+bennodev19@users.noreply.github.com>
Date: Thu, 18 Mar 2021 06:13:01 +0100
Subject: [PATCH 15/35] fixed broken links
---
README.md | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/README.md b/README.md
index b1a1eb54..37059503 100644
--- a/README.md
+++ b/README.md
@@ -55,7 +55,7 @@ const MY_FIRST_STATE = App.createState("Hello Stranger!");
// And wolla its reactive. Everytime the State mutates the Component gets rerendered
const myFirstState = useAgile(MY_FIRST_STATE); // returns value of State ("Hello Stranger!")
```
-To find out more checkout our [documentation](https://agile-ts.org/docs/installation).
+To find out more checkout our [documentation](https://agile-ts.org/docs/introduction).
### β³οΈ Sandbox
Test AgileTs yourself, it's only one click away. Just select your preferred Framework below.
@@ -63,7 +63,7 @@ Test AgileTs yourself, it's only one click away. Just select your preferred Fram
- Vue (coming soon)
- Angular (coming soon)
-More examples can be found in the [Example Section](../examples/Indroduction.md).
+More examples can be found in the [Example Section](https://agile-ts.org/docs/examples).
@@ -103,8 +103,8 @@ Write minimalistic, boilerplate free code that captures your intent.
### π― Easy to Use
Learn the powerful tools of AgileTs in a short amount of time.
-A good place to start are our [Quick Starts](./Installation.md)
-or if you are no fan of following any tutorial, checkout your [examples](../examples).
+A good place to start are our [Quick Starts](https://agile-ts.org/docs/installation)
+or if you are no fan of following any tutorial, checkout your [examples](https://agile-ts.org/docs/examples).
@@ -133,10 +133,10 @@ To properly use AgileTs, in a UI-Framework we need to install **two** packages.
-If AgileTs sounds interesting to you.
-Checkout our **[docs](https://agile-ts.org/docs/)**.
-And I am sure you will be able to use it in no time.
-In case you have any further questions don't mind joining our [Community Discord](https://discord.gg/FTqeMNCxw7).
+Sounds AgileTs interesting to you?
+Checkout our **[documentation](https://agile-ts.org/docs/introduction)**, to learn more.
+And I promise you, you will be able to use AgileTs in no time.
+In case you have any further questions don't mind joining our [Community Discord](https://discord.gg/T9GzreAwPH).
From 5c3cebb49baaec9eca70966490836c2ef546773a Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Sat, 20 Mar 2021 10:15:12 +0100
Subject: [PATCH 16/35] fixed return this in some functions
---
packages/core/src/collection/index.ts | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/packages/core/src/collection/index.ts b/packages/core/src/collection/index.ts
index a96d118d..b9031ca5 100644
--- a/packages/core/src/collection/index.ts
+++ b/packages/core/src/collection/index.ts
@@ -356,7 +356,8 @@ export class Collection {
if (changes[this.config.primaryKey] !== itemKey) {
changes[this.config.primaryKey] = itemKey;
Agile.logger.warn(
- `By overwriting the whole Item don't forget passing the correct primaryKey!`, changes
+ `By overwriting the whole Item don't forget passing the correct primaryKey!`,
+ changes
);
}
@@ -1011,7 +1012,12 @@ export class Collection {
* Remove Items from Collection
* @param itemKeys - ItemKey/s that get removed
*/
- public remove(itemKeys: ItemKey | Array) {
+ public remove(
+ itemKeys: ItemKey | Array
+ ): {
+ fromGroups: (groups: Array | ItemKey) => Collection;
+ everywhere: () => Collection;
+ } {
return {
fromGroups: (groups: Array | ItemKey) =>
this.removeFromGroups(itemKeys, groups),
@@ -1031,7 +1037,7 @@ export class Collection {
public removeFromGroups(
itemKeys: ItemKey | Array,
groupKeys: GroupKey | Array
- ): void {
+ ): this {
const _itemKeys = normalizeArray(itemKeys);
const _groupKeys = normalizeArray(groupKeys);
@@ -1053,6 +1059,8 @@ export class Collection {
)
this.removeItems(itemKey);
});
+
+ return this;
}
//=========================================================================================================
@@ -1063,7 +1071,7 @@ export class Collection {
* Removes Item completely from Collection
* @param itemKeys - ItemKey/s of Item/s
*/
- public removeItems(itemKeys: ItemKey | Array): void {
+ public removeItems(itemKeys: ItemKey | Array): this {
const _itemKeys = normalizeArray(itemKeys);
_itemKeys.forEach((itemKey) => {
@@ -1091,6 +1099,8 @@ export class Collection {
this.size--;
});
+
+ return this;
}
//=========================================================================================================
From 02b1076a42145c166ec0db362d2ccae048b31bc8 Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Sun, 28 Mar 2021 18:38:40 +0200
Subject: [PATCH 17/35] rebuild method returns now this
---
packages/core/src/collection/group.ts | 9 +++++++--
packages/cra-template-agile-typescript/template.json | 3 +--
packages/cra-template-agile/template.json | 3 +--
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/packages/core/src/collection/group.ts b/packages/core/src/collection/group.ts
index 11b1805c..d46f11db 100644
--- a/packages/core/src/collection/group.ts
+++ b/packages/core/src/collection/group.ts
@@ -165,7 +165,10 @@ export class Group extends State> {
* @param itemKeys - ItemKey/s that get added to the Group
* @param config - Config
*/
- public add(itemKeys: ItemKey | ItemKey[], config: GroupAddConfigInterface = {}): this {
+ public add(
+ itemKeys: ItemKey | ItemKey[],
+ config: GroupAddConfigInterface = {}
+ ): this {
const _itemKeys = normalizeArray(itemKeys);
const notExistingItemKeysInCollection: Array = [];
const existingItemKeys: Array = [];
@@ -296,7 +299,7 @@ export class Group extends State> {
* @internal
* Rebuilds Output and Items of Group
*/
- public rebuild() {
+ public rebuild(): this {
const notFoundItemKeys: Array = []; // Item Keys that couldn't be found in Collection
const groupItems: Array- > = [];
@@ -325,6 +328,8 @@ export class Group extends State> {
this.items = groupItems;
this._output = groupOutput;
this.notFoundItemKeys = notFoundItemKeys;
+
+ return this;
}
}
diff --git a/packages/cra-template-agile-typescript/template.json b/packages/cra-template-agile-typescript/template.json
index e55043ae..66fb64e8 100644
--- a/packages/cra-template-agile-typescript/template.json
+++ b/packages/cra-template-agile-typescript/template.json
@@ -6,8 +6,7 @@
"@testing-library/user-event": "^12.1.10",
"web-vitals": "^1.0.1",
"@agile-ts/core": "^0.0.10",
- "@agile-ts/react": "^0.0.10",
- "@agile-ts/api": "^0.0.10"
+ "@agile-ts/react": "^0.0.10"
},
"eslintConfig": {
"extends": ["react-app", "react-app/jest"]
diff --git a/packages/cra-template-agile/template.json b/packages/cra-template-agile/template.json
index e55043ae..66fb64e8 100644
--- a/packages/cra-template-agile/template.json
+++ b/packages/cra-template-agile/template.json
@@ -6,8 +6,7 @@
"@testing-library/user-event": "^12.1.10",
"web-vitals": "^1.0.1",
"@agile-ts/core": "^0.0.10",
- "@agile-ts/react": "^0.0.10",
- "@agile-ts/api": "^0.0.10"
+ "@agile-ts/react": "^0.0.10"
},
"eslintConfig": {
"extends": ["react-app", "react-app/jest"]
From ba9ecf278f319a44885db72779f26bde4bc190a9 Mon Sep 17 00:00:00 2001
From: BennoDev <57860196+bennodev19@users.noreply.github.com>
Date: Sun, 28 Mar 2021 20:44:46 +0200
Subject: [PATCH 18/35] fixed typo in readme
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 37059503..fe9a8cbd 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
- > AgileTs is a global, simple, spacy State and Logic Framework
+ > Global, simple, spacy State and Logic Framework
From caf26231b1e6bd7ebb336c83514d9a0c0736ca15 Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Mon, 29 Mar 2021 06:53:43 +0200
Subject: [PATCH 19/35] updated package.jsons
---
CONTRIBUTING.md | 8 +--
.../react-native/AwesomeTSProject/README.md | 8 +--
.../AwesomeTSProject/package.json | 2 +-
examples/react/class-component-ts/README.md | 8 +--
.../react/class-component-ts/package.json | 2 +-
.../react/functional-component-ts/README.md | 8 +--
.../functional-component-ts/package.json | 3 +-
examples/react/multieditor-ts/README.md | 8 +--
examples/react/multieditor-ts/package.json | 2 +-
package.json | 6 +-
packages/api/package.json | 6 +-
packages/core/package.json | 6 +-
packages/event/CHANGELOG.md | 69 +++++++++++++++++++
packages/event/LICENSE | 21 ++++++
packages/event/README.md | 40 +++++++++++
packages/event/jest.config.js | 7 ++
packages/event/package.json | 43 ++++++++++++
packages/event/tsconfig.json | 10 +++
packages/event/tsconfig.production.json | 7 ++
packages/multieditor/package.json | 6 +-
packages/react/package.json | 6 +-
21 files changed, 237 insertions(+), 39 deletions(-)
create mode 100644 packages/event/CHANGELOG.md
create mode 100644 packages/event/LICENSE
create mode 100644 packages/event/README.md
create mode 100644 packages/event/jest.config.js
create mode 100644 packages/event/package.json
create mode 100644 packages/event/tsconfig.json
create mode 100644 packages/event/tsconfig.production.json
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 6ffe2f3a..0d5b1734 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -75,17 +75,17 @@ Don't take this personally if this happens, and feel free to open a new issue on
## β³ Installation
1. Ensure you have [Yarn](https://yarnpkg.com/) installed
-2. After cloning the repository, run `yarn run install-packages` in the root of the repository,
+2. After cloning the repository, run `yarn run install:agile` in the root of the repository,
which simply runs `yarn install` in each package to ensure all dependencies are installed.
### Run Example Project's
1. Follow the [Installation](#Installation) steps above
2. Ensure you have [Yalc](https://www.google.com/search?client=firefox-b-d&q=yalc) installed
-3. Run `yarn run dev-publish` to publish all packages in your local 'npm store'
+3. Run `yarn run dev:publish` to publish all packages in your local 'npm store'
4. Execute `yarn install` in the Example Project to install its dependencies like AgileTs
-5. If you made your desired changes. Run `yarn run dev-push` to push your updated changes into your local 'npm store'
- _ProTip:_ To make realtime changes, run `yarn run watch`, which automatically runs `yarn run dev-push` everytime you update a file in a package.
+5. If you made your desired changes. Run `yarn run dev:push` to push your updated changes into your local 'npm store'
+ _ProTip:_ To make realtime changes, run `yarn run watch`, which automatically runs `yarn run dev:push` everytime you update a file in a package.
## βοΈ Pull Request
diff --git a/examples/react-native/AwesomeTSProject/README.md b/examples/react-native/AwesomeTSProject/README.md
index 3813517e..7fe35f54 100644
--- a/examples/react-native/AwesomeTSProject/README.md
+++ b/examples/react-native/AwesomeTSProject/README.md
@@ -14,18 +14,18 @@ This Example represents the basic features of the `core` package in a **function
#### 1. Run `npm install` at the root of Agile
At first, we have to install some 'global' dependencies of AgileTs.
-#### 2. Run `npm run install-all` at the root of Agile
+#### 2. Run `npm run install:agile` at the root of Agile
Then we install the dependencies of all AgileTs Packages (core, react, api, ..)
-#### 3. Run `npm run dev-publish` at the root of Agile
+#### 3. Run `npm run dev:publish` at the root of Agile
As next step we `publish` all AgileTs Packages to our local `yalc` repository,
to import them later in our examples.
-#### 4. Run `npm run install-agile` in this Project
+#### 4. Run `npm run install:agile` in this Project
To run the example we have to install the dependencies of it, too.
We aren't using `npm install`, because we want to add the just published AgileTs Packages properly.
-#### 5. Run `npm run dev-push` at the root of Agile
+#### 5. Run `npm run dev:push` at the root of Agile
After 'publishing' the AgileTs Packages and installing the dependencies of the example, we can push our changes,
which we might have made for instance in the core package, to yalc by running this command.
All projects having a dependency of the pushed package will receive the changes immediately.
diff --git a/examples/react-native/AwesomeTSProject/package.json b/examples/react-native/AwesomeTSProject/package.json
index 2b944aa8..e41e5b67 100644
--- a/examples/react-native/AwesomeTSProject/package.json
+++ b/examples/react-native/AwesomeTSProject/package.json
@@ -8,7 +8,7 @@
"start": "react-native start",
"test": "jest",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
- "install-agile": "yalc add @agile-ts/core @agile-ts/react @agile-ts/api & yarn install"
+ "install:agile": "yalc add @agile-ts/core @agile-ts/react @agile-ts/api & yarn install"
},
"dependencies": {
"@agile-ts/api": "file:.yalc/@agile-ts/api",
diff --git a/examples/react/class-component-ts/README.md b/examples/react/class-component-ts/README.md
index 5c81f6c1..be435310 100644
--- a/examples/react/class-component-ts/README.md
+++ b/examples/react/class-component-ts/README.md
@@ -14,18 +14,18 @@ This Example represents the basic features of the `core` package in a **class co
#### 1. Run `npm install` at the root of Agile
At first, we have to install some 'global' dependencies of AgileTs.
-#### 2. Run `npm run install-all` at the root of Agile
+#### 2. Run `npm run install:agile` at the root of Agile
Then we install the dependencies of all AgileTs Packages (core, react, api, ..)
-#### 3. Run `npm run dev-publish` at the root of Agile
+#### 3. Run `npm run dev:publish` at the root of Agile
As next step we `publish` all AgileTs Packages to our local `yalc` repository,
to import them later in our examples.
-#### 4. Run `npm run install-agile` in this Project
+#### 4. Run `npm run install:agile` in this Project
To run the example we have to install the dependencies of it, too.
We aren't using `npm install`, because we want to add the just published AgileTs Packages properly.
-#### 5. Run `npm run dev-push` at the root of Agile
+#### 5. Run `npm run dev:push` at the root of Agile
After 'publishing' the AgileTs Packages and installing the dependencies of the example, we can push our changes,
which we might have made for instance in the core package, to yalc by running this command.
All projects having a dependency of the pushed package will receive the changes immediately.
diff --git a/examples/react/class-component-ts/package.json b/examples/react/class-component-ts/package.json
index 6cb357be..dbd9687f 100644
--- a/examples/react/class-component-ts/package.json
+++ b/examples/react/class-component-ts/package.json
@@ -28,7 +28,7 @@
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
- "install-agile": "yalc add @agile-ts/core @agile-ts/react @agile-ts/api @agile-ts/multieditor & yarn install"
+ "install:agile": "yalc add @agile-ts/core @agile-ts/react @agile-ts/api @agile-ts/multieditor @agile-ts/event & yarn install"
},
"eslintConfig": {
"extends": "react-app"
diff --git a/examples/react/functional-component-ts/README.md b/examples/react/functional-component-ts/README.md
index 17950747..2b0f7343 100644
--- a/examples/react/functional-component-ts/README.md
+++ b/examples/react/functional-component-ts/README.md
@@ -14,18 +14,18 @@ This Example represents the basic features of the `core` package in a **function
#### 1. Run `npm install` at the root of Agile
At first, we have to install some 'global' dependencies of AgileTs.
-#### 2. Run `npm run install-all` at the root of Agile
+#### 2. Run `npm run install:agile` at the root of Agile
Then we install the dependencies of all AgileTs Packages (core, react, api, ..)
-#### 3. Run `npm run dev-publish` at the root of Agile
+#### 3. Run `npm run dev:publish` at the root of Agile
As next step we `publish` all AgileTs Packages to our local `yalc` repository,
to import them later in our examples.
-#### 4. Run `npm run install-agile` in this Project
+#### 4. Run `npm run install:agile` in this Project
To run the example we have to install the dependencies of it, too.
We aren't using `npm install`, because we want to add the just published AgileTs Packages properly.
-#### 5. Run `npm run dev-push` at the root of Agile
+#### 5. Run `npm run dev:push` at the root of Agile
After 'publishing' the AgileTs Packages and installing the dependencies of the example, we can push our changes,
which we might have made for instance in the core package, to yalc by running this command.
All projects having a dependency of the pushed package will receive the changes immediately.
diff --git a/examples/react/functional-component-ts/package.json b/examples/react/functional-component-ts/package.json
index 7d73327f..c9627edb 100644
--- a/examples/react/functional-component-ts/package.json
+++ b/examples/react/functional-component-ts/package.json
@@ -7,6 +7,7 @@
"@agile-ts/core": "file:.yalc/@agile-ts/core",
"@agile-ts/multieditor": "file:.yalc/@agile-ts/multieditor",
"@agile-ts/react": "file:.yalc/@agile-ts/react",
+ "@agile-ts/event": "file:.yalc/@agile-ts/event",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-router-dom": "^5.2.0",
@@ -28,7 +29,7 @@
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
- "install-agile": "yalc add @agile-ts/core @agile-ts/react @agile-ts/api @agile-ts/multieditor & yarn install"
+ "install:agile": "yalc add @agile-ts/core @agile-ts/react @agile-ts/api @agile-ts/multieditor @agile-ts/event & yarn install"
},
"eslintConfig": {
"extends": "react-app"
diff --git a/examples/react/multieditor-ts/README.md b/examples/react/multieditor-ts/README.md
index 1d6d2186..eb14ae46 100644
--- a/examples/react/multieditor-ts/README.md
+++ b/examples/react/multieditor-ts/README.md
@@ -14,18 +14,18 @@ This Example represents the basic features of the `multieditor` package in a **f
#### 1. Run `npm install` at the root of Agile
At first, we have to install some 'global' dependencies of AgileTs.
-#### 2. Run `npm run install-all` at the root of Agile
+#### 2. Run `npm run install:agile` at the root of Agile
Then we install the dependencies of all AgileTs Packages (core, react, api, ..)
-#### 3. Run `npm run dev-publish` at the root of Agile
+#### 3. Run `npm run dev:publish` at the root of Agile
As next step we `publish` all AgileTs Packages to our local `yalc` repository,
to import them later in our examples.
-#### 4. Run `npm run install-agile` in this Project
+#### 4. Run `npm run install:agile` in this Project
To run the example we have to install the dependencies of it, too.
We aren't using `npm install`, because we want to add the just published AgileTs Packages properly.
-#### 5. Run `npm run dev-push` at the root of Agile
+#### 5. Run `npm run dev:push` at the root of Agile
After 'publishing' the AgileTs Packages and installing the dependencies of the example, we can push our changes,
which we might have made for instance in the core package, to yalc by running this command.
All projects having a dependency of the pushed package will receive the changes immediately.
diff --git a/examples/react/multieditor-ts/package.json b/examples/react/multieditor-ts/package.json
index 3977e646..1c8a5e8c 100644
--- a/examples/react/multieditor-ts/package.json
+++ b/examples/react/multieditor-ts/package.json
@@ -26,7 +26,7 @@
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
- "install-agile": "yalc add @agile-ts/core @agile-ts/react @agile-ts/multieditor & yarn install"
+ "install:agile": "yalc add @agile-ts/core @agile-ts/react @agile-ts/multieditor & yarn install"
},
"eslintConfig": {
"extends": [
diff --git a/package.json b/package.json
index 8d608773..0751b03a 100644
--- a/package.json
+++ b/package.json
@@ -23,10 +23,10 @@
"watch:api": "cd packages/core && yarn run watch",
"test": "jest --passWithNoTests",
"test:coverage": "jest --coverage",
- "dev-publish": "lerna run build && lerna run dev-publish",
- "dev-push": "lerna run build && lerna run dev-push",
+ "dev:publish": "lerna run build && lerna run dev:publish",
+ "dev:push": "lerna run build && lerna run dev:push",
"install:packages": "lerna exec yarn install",
- "bump-version": "changeset",
+ "version:bump": "changeset",
"release": "lerna run release && changeset publish",
"prettier": "prettier --config .prettierrc --write \"**/*.{js,ts}\"",
"lint": "eslint --cache \"**/*.{js,jsx,ts,tsx}\"",
diff --git a/packages/api/package.json b/packages/api/package.json
index a398390c..4e6d0ff9 100644
--- a/packages/api/package.json
+++ b/packages/api/package.json
@@ -17,9 +17,9 @@
"scripts": {
"build": "tsc",
"prepare": "tsc && tsc -p ./tsconfig.production.json",
- "dev-publish": "yalc publish",
- "dev-push": "yalc push",
- "watch": "tsc-watch --onSuccess \"yarn run dev-push\"",
+ "dev:publish": "yalc publish",
+ "dev:push": "yalc push",
+ "watch": "tsc-watch --onSuccess \"yarn run dev:push\"",
"release": "yarn run prepare",
"preview": "npm pack"
},
diff --git a/packages/core/package.json b/packages/core/package.json
index 08ad2296..1b7d591a 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -18,9 +18,9 @@
"scripts": {
"build": "tsc",
"prepare": "tsc && tsc -p ./tsconfig.production.json",
- "dev-publish": "yalc publish",
- "dev-push": "yalc push",
- "watch": "tsc-watch --onSuccess \"yarn run dev-push\"",
+ "dev:publish": "yalc publish",
+ "dev:push": "yalc push",
+ "watch": "tsc-watch --onSuccess \"yarn run dev:push\"",
"release": "node ./scripts/prepublish.js && yarn run prepare",
"preview": "npm pack"
},
diff --git a/packages/event/CHANGELOG.md b/packages/event/CHANGELOG.md
new file mode 100644
index 00000000..6920262e
--- /dev/null
+++ b/packages/event/CHANGELOG.md
@@ -0,0 +1,69 @@
+# Change Log
+
+## 0.0.13
+
+### Patch Changes
+
+- Updated dependencies [9071dd6]
+ - @agile-ts/core@0.0.12
+
+## 0.0.12
+
+### Patch Changes
+
+- e0366b3: fixed building url without path
+
+## 0.0.11
+
+### Patch Changes
+
+- Updated dependencies [93ead02]
+ - @agile-ts/core@0.0.11
+
+## 0.0.10
+
+### Patch Changes
+
+- Updated dependencies [9a09652]
+ - @agile-ts/core@0.0.10
+
+## 0.0.9
+
+### Patch Changes
+
+- Updated dependencies [c3a8217]
+ - @agile-ts/core@0.0.9
+
+## 0.0.8
+
+### Patch Changes
+
+- 198c212: added prettier and eslint and fixed some small issues
+- Updated dependencies [198c212]
+ - @agile-ts/core@0.0.8
+
+## 0.0.7
+
+### Patch Changes
+
+- 7f89382: Updated ReadMe's
+- Updated dependencies [7f89382]
+ - @agile-ts/core@0.0.7
+
+## 0.0.6
+
+### Patch Changes
+
+- 86e6890: Updated Tests in Core | Fixed some Bugs
+- Updated dependencies [86e6890]
+ - @agile-ts/core@0.0.6
+
+All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
+
+## [0.0.5](https://github.com/agile-ts/agile/compare/v0.0.4...v0.0.5) (2020-11-05)
+
+**Note:** Version bump only for package @agile-ts/api
+
+## 0.0.4 (2020-11-03)
+
+**Note:** Version bump only for package @agile-ts/api
diff --git a/packages/event/LICENSE b/packages/event/LICENSE
new file mode 100644
index 00000000..b93156fb
--- /dev/null
+++ b/packages/event/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2020-present bennodev19
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/packages/event/README.md b/packages/event/README.md
new file mode 100644
index 00000000..ff03d151
--- /dev/null
+++ b/packages/event/README.md
@@ -0,0 +1,40 @@
+# [WIP] Event
+
+> Handy class for emitting UI updates and passing data with them.
+
+
+
+
+
+
+
+
+
+
+
+
+## β° Short Example
+```ts
+const MY_EVENT = App.createEvent();
+MY_EVENT.on((data) => {console.log("hello there " + data.name)}); // Print 'hello there jeff' if Event gets triggered
+MY_EVENT.trigger({name: "jeff"}); // Trigger Event
+```
+
+## β¬οΈ Installation
+```
+npm install @agile-ts/event
+```
+_Be aware that this is no standalone package!_
+To use the Agile Api you have to install the [Agile Core](https://www.npmjs.com/package/@agile-ts/core).
+To find out more take a look into the [docs](https://www.agile-ts.org/docs).
+
+
+## π Fitting Versions
+| @agile-ts/api | @agile-ts/core | NPM Version |
+| --------------- | ----------------------- | ------------------------ |
+| v0.0.7 | v0.0.1+ | v6+ |
+| v0.0.6 | v0.0.1+ | v6+ |
+_Other Versions aren't supported anymore_
+
+## π Documentation
+The Agile Api Docs are located [here](https://agile-ts.org/docs/)
diff --git a/packages/event/jest.config.js b/packages/event/jest.config.js
new file mode 100644
index 00000000..e7c8d896
--- /dev/null
+++ b/packages/event/jest.config.js
@@ -0,0 +1,7 @@
+const baseConfig = require('../../jest.config.base');
+
+module.exports = {
+ ...baseConfig,
+ rootDir: '../..',
+ name: 'Event',
+};
diff --git a/packages/event/package.json b/packages/event/package.json
new file mode 100644
index 00000000..3e3e6b28
--- /dev/null
+++ b/packages/event/package.json
@@ -0,0 +1,43 @@
+{
+ "name": "@agile-ts/event",
+ "version": "0.0.1",
+ "author": "BennoDev",
+ "license": "MIT",
+ "homepage": "https://agile-ts.org/",
+ "description": "Handy class for emitting UI updates and passing data with them",
+ "keywords": [
+ "agile",
+ "agile-ts",
+ "event",
+ "ui-event"
+ ],
+ "main": "dist/index.js",
+ "types": "dist/index.d.ts",
+ "scripts": {
+ "build": "tsc",
+ "prepare": "tsc && tsc -p ./tsconfig.production.json",
+ "dev:publish": "yalc publish",
+ "dev:push": "yalc push",
+ "watch": "tsc-watch --onSuccess \"yarn run dev:push\"",
+ "release": "yarn run prepare",
+ "preview": "npm pack"
+ },
+ "devDependencies": {
+ "@agile-ts/core": "file:../core"
+ },
+ "peerDependencies": {
+ "@agile-ts/core": "^0.0.12"
+ },
+ "publishConfig": {
+ "access": "public"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/agile-ts/agile.git"
+ },
+ "files": [
+ "dist",
+ "LICENSE",
+ "README.md"
+ ]
+}
diff --git a/packages/event/tsconfig.json b/packages/event/tsconfig.json
new file mode 100644
index 00000000..600cd205
--- /dev/null
+++ b/packages/event/tsconfig.json
@@ -0,0 +1,10 @@
+{
+ "extends": "../tsconfig.default.json",
+ "compilerOptions": {
+ "rootDir": "src",
+ "outDir": "dist"
+ },
+ "include": [
+ "./src/**/*" // Only include what is in src (-> dist, tests, .. will be excluded)
+ ]
+}
\ No newline at end of file
diff --git a/packages/event/tsconfig.production.json b/packages/event/tsconfig.production.json
new file mode 100644
index 00000000..4b5c4d12
--- /dev/null
+++ b/packages/event/tsconfig.production.json
@@ -0,0 +1,7 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "declaration": false,
+ "removeComments": true
+ }
+}
\ No newline at end of file
diff --git a/packages/multieditor/package.json b/packages/multieditor/package.json
index 09bd0980..af294ba4 100644
--- a/packages/multieditor/package.json
+++ b/packages/multieditor/package.json
@@ -19,9 +19,9 @@
"scripts": {
"build": "tsc",
"prepare": "tsc && tsc -p ./tsconfig.production.json",
- "dev-publish": "yalc publish",
- "dev-push": "yalc push",
- "watch": "tsc-watch --onSuccess \"yarn run dev-push\"",
+ "dev:publish": "yalc publish",
+ "dev:push": "yalc push",
+ "watch": "tsc-watch --onSuccess \"yarn run dev:push\"",
"release": "yarn run prepare",
"preview": "npm pack"
},
diff --git a/packages/react/package.json b/packages/react/package.json
index 8158db6d..fe9a7cc3 100644
--- a/packages/react/package.json
+++ b/packages/react/package.json
@@ -19,9 +19,9 @@
"scripts": {
"build": "tsc",
"prepare": "tsc && tsc -p ./tsconfig.production.json",
- "dev-publish": "yalc publish",
- "dev-push": "yalc push",
- "watch": "tsc-watch --onSuccess \"yarn run dev-push\"",
+ "dev:publish": "yalc publish",
+ "dev:push": "yalc push",
+ "watch": "tsc-watch --onSuccess \"yarn run dev:push\"",
"release": "yarn run prepare",
"preview": "npm pack"
},
From 35f4814300592fb5359ef9a6716dab285cc28076 Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Mon, 29 Mar 2021 06:54:05 +0200
Subject: [PATCH 20/35] created event.class
---
packages/core/src/agile.ts | 17 -----------------
packages/core/src/computed/index.ts | 3 +--
packages/core/src/internal.ts | 5 -----
.../{core/src/event => event/src}/event.job.ts | 0
.../src/event => event/src}/event.observer.ts | 4 ++--
.../src/event/index.ts => event/src/event.ts} | 5 ++---
packages/event/src/index.ts | 4 ++++
packages/event/src/internal.ts | 9 +++++++++
8 files changed, 18 insertions(+), 29 deletions(-)
rename packages/{core/src/event => event/src}/event.job.ts (100%)
rename packages/{core/src/event => event/src}/event.observer.ts (95%)
rename packages/{core/src/event/index.ts => event/src/event.ts} (99%)
create mode 100644 packages/event/src/index.ts
create mode 100644 packages/event/src/internal.ts
diff --git a/packages/core/src/agile.ts b/packages/core/src/agile.ts
index 2c08c887..5f424289 100644
--- a/packages/core/src/agile.ts
+++ b/packages/core/src/agile.ts
@@ -7,9 +7,6 @@ import {
CollectionConfig,
DefaultItem,
Computed,
- Event,
- CreateEventConfigInterface,
- DefaultEventPayload,
Integrations,
Observer,
SubController,
@@ -176,20 +173,6 @@ export class Agile {
);
}
- //=========================================================================================================
- // Event
- //=========================================================================================================
- /**
- * @public
- * Event - Class that holds a List of Functions which can be triggered at the same time
- * @param config - Config
- */
- public createEvent(
- config?: CreateEventConfigInterface
- ) {
- return new Event(this, config);
- }
-
//=========================================================================================================
// Integrate
//=========================================================================================================
diff --git a/packages/core/src/computed/index.ts b/packages/core/src/computed/index.ts
index 55d9f6b4..f687f948 100644
--- a/packages/core/src/computed/index.ts
+++ b/packages/core/src/computed/index.ts
@@ -3,7 +3,6 @@ import {
Agile,
defineConfig,
Observer,
- Event,
StateConfigInterface,
ComputedTracker,
Group,
@@ -183,7 +182,7 @@ export class Computed extends State<
* @param computedDeps - Hard coded dependencies of Computed Function
*/
export interface ComputedConfigInterface extends StateConfigInterface {
- computedDeps?: Array;
+ computedDeps?: Array;
}
/**
diff --git a/packages/core/src/internal.ts b/packages/core/src/internal.ts
index 756f97e8..2be3650a 100644
--- a/packages/core/src/internal.ts
+++ b/packages/core/src/internal.ts
@@ -44,11 +44,6 @@ export * from './collection/item';
export * from './collection/selector';
export * from './collection/collection.persistent';
-// Event
-export * from './event';
-export * from './event/event.job';
-export * from './event/event.observer';
-
// Integrations
export * from './integrations';
export * from './integrations/integration';
diff --git a/packages/core/src/event/event.job.ts b/packages/event/src/event.job.ts
similarity index 100%
rename from packages/core/src/event/event.job.ts
rename to packages/event/src/event.job.ts
diff --git a/packages/core/src/event/event.observer.ts b/packages/event/src/event.observer.ts
similarity index 95%
rename from packages/core/src/event/event.observer.ts
rename to packages/event/src/event.observer.ts
index 5780c98b..97da3216 100644
--- a/packages/core/src/event/event.observer.ts
+++ b/packages/event/src/event.observer.ts
@@ -2,9 +2,9 @@ import {
Observer,
RuntimeJob,
ObserverKey,
- Event,
SubscriptionContainer,
-} from '../internal';
+} from '@agile-ts/core';
+import { Event } from './internal';
export class EventObserver extends Observer {
public event: () => Event;
diff --git a/packages/core/src/event/index.ts b/packages/event/src/event.ts
similarity index 99%
rename from packages/core/src/event/index.ts
rename to packages/event/src/event.ts
index 7867752a..3e4a1c55 100644
--- a/packages/core/src/event/index.ts
+++ b/packages/event/src/event.ts
@@ -1,12 +1,11 @@
import {
Agile,
defineConfig,
- EventJob,
generateId,
isFunction,
Observer,
-} from '../internal';
-import { EventObserver } from './event.observer';
+} from '@agile-ts/core';
+import { EventObserver, EventJob } from './internal';
export class Event {
public agileInstance: () => Agile;
diff --git a/packages/event/src/index.ts b/packages/event/src/index.ts
new file mode 100644
index 00000000..3cb08d20
--- /dev/null
+++ b/packages/event/src/index.ts
@@ -0,0 +1,4 @@
+import { Event } from './internal';
+
+export * from './internal';
+export default Event;
diff --git a/packages/event/src/internal.ts b/packages/event/src/internal.ts
new file mode 100644
index 00000000..e63a1ffb
--- /dev/null
+++ b/packages/event/src/internal.ts
@@ -0,0 +1,9 @@
+// This file exposes Agile Editor functions and types to the outside world
+// It also serves as a cyclic dependency workaround
+// https://medium.com/visual-development/how-to-fix-nasty-circular-dependency-issues-once-and-for-all-in-javascript-typescript-a04c987cf0de.
+
+// !! All internal Agile Editor modules must be imported from here!!
+
+export * from './event.job';
+export * from './event.observer';
+export * from './event';
From 120a2b212900a4e8cd9a626a88496370a401eed7 Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Mon, 29 Mar 2021 06:55:16 +0200
Subject: [PATCH 21/35] updated example
---
.../react/functional-component-ts/src/core/index.ts | 3 ++-
examples/react/functional-component-ts/yarn.lock | 11 +++++++----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/examples/react/functional-component-ts/src/core/index.ts b/examples/react/functional-component-ts/src/core/index.ts
index b812c014..c3fa7e91 100644
--- a/examples/react/functional-component-ts/src/core/index.ts
+++ b/examples/react/functional-component-ts/src/core/index.ts
@@ -1,5 +1,6 @@
import { Agile, clone, Logger } from '@agile-ts/core';
import API from '@agile-ts/api';
+import Event from '@agile-ts/event';
export const App = new Agile({
logConfig: { level: Logger.level.DEBUG },
@@ -51,7 +52,7 @@ MY_COLLECTION.onLoad(() => {
console.log('Initial: myCollection ', clone(MY_COLLECTION));
-export const MY_EVENT = App.createEvent<{ name: string }>({
+export const MY_EVENT = new Event<{ name: string }>(App, {
delay: 3000,
key: 'myEvent',
});
diff --git a/examples/react/functional-component-ts/yarn.lock b/examples/react/functional-component-ts/yarn.lock
index 4c0a4379..dbc7bc96 100644
--- a/examples/react/functional-component-ts/yarn.lock
+++ b/examples/react/functional-component-ts/yarn.lock
@@ -3,16 +3,19 @@
"@agile-ts/api@file:.yalc/@agile-ts/api":
- version "0.0.11"
+ version "0.0.13"
"@agile-ts/core@file:.yalc/@agile-ts/core":
- version "0.0.11"
+ version "0.0.12"
+
+"@agile-ts/event@file:.yalc/@agile-ts/event":
+ version "0.0.1"
"@agile-ts/multieditor@file:.yalc/@agile-ts/multieditor":
- version "0.0.11"
+ version "0.0.12"
"@agile-ts/react@file:.yalc/@agile-ts/react":
- version "0.0.11"
+ version "0.0.12"
"@babel/code-frame@7.8.3":
version "7.8.3"
From 4d719c5cd4de38d90c1c6ead6baf99e5ace4fcc4 Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Mon, 29 Mar 2021 06:58:43 +0200
Subject: [PATCH 22/35] removed changelog
---
packages/api/CHANGELOG.md | 69 ---------------------------------------
1 file changed, 69 deletions(-)
delete mode 100644 packages/api/CHANGELOG.md
diff --git a/packages/api/CHANGELOG.md b/packages/api/CHANGELOG.md
deleted file mode 100644
index 6920262e..00000000
--- a/packages/api/CHANGELOG.md
+++ /dev/null
@@ -1,69 +0,0 @@
-# Change Log
-
-## 0.0.13
-
-### Patch Changes
-
-- Updated dependencies [9071dd6]
- - @agile-ts/core@0.0.12
-
-## 0.0.12
-
-### Patch Changes
-
-- e0366b3: fixed building url without path
-
-## 0.0.11
-
-### Patch Changes
-
-- Updated dependencies [93ead02]
- - @agile-ts/core@0.0.11
-
-## 0.0.10
-
-### Patch Changes
-
-- Updated dependencies [9a09652]
- - @agile-ts/core@0.0.10
-
-## 0.0.9
-
-### Patch Changes
-
-- Updated dependencies [c3a8217]
- - @agile-ts/core@0.0.9
-
-## 0.0.8
-
-### Patch Changes
-
-- 198c212: added prettier and eslint and fixed some small issues
-- Updated dependencies [198c212]
- - @agile-ts/core@0.0.8
-
-## 0.0.7
-
-### Patch Changes
-
-- 7f89382: Updated ReadMe's
-- Updated dependencies [7f89382]
- - @agile-ts/core@0.0.7
-
-## 0.0.6
-
-### Patch Changes
-
-- 86e6890: Updated Tests in Core | Fixed some Bugs
-- Updated dependencies [86e6890]
- - @agile-ts/core@0.0.6
-
-All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
-
-## [0.0.5](https://github.com/agile-ts/agile/compare/v0.0.4...v0.0.5) (2020-11-05)
-
-**Note:** Version bump only for package @agile-ts/api
-
-## 0.0.4 (2020-11-03)
-
-**Note:** Version bump only for package @agile-ts/api
From e205fffddde44d902a9243c4a96897e8981d36ad Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Mon, 29 Mar 2021 07:49:25 +0200
Subject: [PATCH 23/35] added basic event tests
---
packages/core/tests/unit/agile.test.ts | 23 -------------------
packages/core/tests/unit/utils.test.ts | 7 ------
.../tests/unit}/event.job.test.ts | 2 +-
.../tests/unit}/event.observer.test.ts | 10 ++------
.../event => event/tests/unit}/event.test.ts | 5 ++--
5 files changed, 6 insertions(+), 41 deletions(-)
rename packages/{core/tests/unit/event => event/tests/unit}/event.job.test.ts (95%)
rename packages/{core/tests/unit/event => event/tests/unit}/event.observer.test.ts (94%)
rename packages/{core/tests/unit/event => event/tests/unit}/event.test.ts (98%)
diff --git a/packages/core/tests/unit/agile.test.ts b/packages/core/tests/unit/agile.test.ts
index 9aa507da..ea1089cb 100644
--- a/packages/core/tests/unit/agile.test.ts
+++ b/packages/core/tests/unit/agile.test.ts
@@ -5,7 +5,6 @@ import {
SubController,
Integrations,
Storage,
- Event,
Computed,
Collection,
Logger,
@@ -247,28 +246,6 @@ describe('Agile Tests', () => {
});
});
- describe('createEvent function tests', () => {
- const EventMock = Event as jest.MockedClass;
-
- beforeEach(() => {
- EventMock.mockClear();
- });
-
- it('should create Event', () => {
- const eventConfig = {
- rerender: true,
- delay: 1000,
- enabled: true,
- key: 'myCoolEvent',
- };
-
- const event = agile.createEvent(eventConfig);
-
- expect(event).toBeInstanceOf(Event);
- expect(EventMock).toHaveBeenCalledWith(agile, eventConfig);
- });
- });
-
describe('integrate function tests', () => {
it('should integrate provided Framework', () => {
const returnedAgile = agile.integrate(testIntegration);
diff --git a/packages/core/tests/unit/utils.test.ts b/packages/core/tests/unit/utils.test.ts
index 739c5f28..5323928c 100644
--- a/packages/core/tests/unit/utils.test.ts
+++ b/packages/core/tests/unit/utils.test.ts
@@ -17,7 +17,6 @@ import {
getAgileInstance,
Agile,
State,
- Event,
Observer,
Collection,
createArrayFromObject,
@@ -208,12 +207,6 @@ describe('Utils Tests', () => {
expect(getAgileInstance(dummyState)).toBe(dummyAgile);
});
- it('should get agileInstance from Event', () => {
- const dummyEvent = new Event(dummyAgile);
-
- expect(getAgileInstance(dummyEvent)).toBe(dummyAgile);
- });
-
it('should get agileInstance from Collection', () => {
const dummyCollection = new Collection(dummyAgile);
diff --git a/packages/core/tests/unit/event/event.job.test.ts b/packages/event/tests/unit/event.job.test.ts
similarity index 95%
rename from packages/core/tests/unit/event/event.job.test.ts
rename to packages/event/tests/unit/event.job.test.ts
index fa066972..2ceb962c 100644
--- a/packages/core/tests/unit/event/event.job.test.ts
+++ b/packages/event/tests/unit/event.job.test.ts
@@ -1,4 +1,4 @@
-import { EventJob } from '../../../src';
+import { EventJob } from '../../src';
describe('EventJob Tests', () => {
it('should create EventJob (without keys)', () => {
diff --git a/packages/core/tests/unit/event/event.observer.test.ts b/packages/event/tests/unit/event.observer.test.ts
similarity index 94%
rename from packages/core/tests/unit/event/event.observer.test.ts
rename to packages/event/tests/unit/event.observer.test.ts
index 8a34af06..2760361b 100644
--- a/packages/core/tests/unit/event/event.observer.test.ts
+++ b/packages/event/tests/unit/event.observer.test.ts
@@ -1,11 +1,5 @@
-import {
- EventObserver,
- Agile,
- Observer,
- SubscriptionContainer,
- Event,
- RuntimeJob,
-} from '../../../src';
+import { EventObserver, Event } from '../../src';
+import { Agile, Observer, SubscriptionContainer } from '@agile-ts/core';
describe('EventObserver Tests', () => {
let dummyAgile: Agile;
diff --git a/packages/core/tests/unit/event/event.test.ts b/packages/event/tests/unit/event.test.ts
similarity index 98%
rename from packages/core/tests/unit/event/event.test.ts
rename to packages/event/tests/unit/event.test.ts
index 8fb38f6a..9867358d 100644
--- a/packages/core/tests/unit/event/event.test.ts
+++ b/packages/event/tests/unit/event.test.ts
@@ -1,5 +1,6 @@
-import { Event, Agile, Observer, EventObserver } from '../../../src';
-import * as Utils from '../../../src/utils';
+import { Event, EventObserver } from '../../src';
+import { Agile, Observer } from '@agile-ts/core';
+import * as Utils from '@agile-ts/core';
describe('Event Tests', () => {
let dummyAgile: Agile;
From 39b39bf55dc3dae1bccd3b4139144a497db875d8 Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Mon, 29 Mar 2021 07:49:34 +0200
Subject: [PATCH 24/35] updated jest config
---
jest.config.base.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/jest.config.base.js b/jest.config.base.js
index ab45f35b..aea580eb 100644
--- a/jest.config.base.js
+++ b/jest.config.base.js
@@ -1,7 +1,7 @@
module.exports = {
testEnvironment: 'node',
coveragePathIgnorePatterns: ['(tests/.*.mock).(jsx?|tsx?)$'],
- modulePathIgnorePatterns: ['dist'],
+ modulePathIgnorePatterns: ['dist', 'examples'],
testMatch: ['/packages/**/tests/**/*.test.ts'],
transform: {
'^.+\\.ts?$': 'ts-jest',
From 352492b84e67041eff1e6ddeee648b616952aafe Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Mon, 29 Mar 2021 13:38:17 +0200
Subject: [PATCH 25/35] fixed jest config
---
jest.config.base.js | 8 +++++++-
packages/event/tests/unit/event.test.ts | 6 +++---
packages/multieditor/jest.config.js | 2 +-
packages/react/tsconfig.json | 1 -
yarn.lock | 5 ++++-
5 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/jest.config.base.js b/jest.config.base.js
index aea580eb..e87caab1 100644
--- a/jest.config.base.js
+++ b/jest.config.base.js
@@ -1,9 +1,15 @@
module.exports = {
testEnvironment: 'node',
coveragePathIgnorePatterns: ['(tests/.*.mock).(jsx?|tsx?)$'],
- modulePathIgnorePatterns: ['dist', 'examples'],
+ modulePathIgnorePatterns: ['dist', 'examples', 'node_modules'],
testMatch: ['/packages/**/tests/**/*.test.ts'],
transform: {
'^.+\\.ts?$': 'ts-jest',
},
+ /* https://stackoverflow.com/questions/63904196/esmoduleinterop-flag-set-still-getting-default-import-error */
+ globals: {
+ 'ts-jest': {
+ tsconfig: '/packages/tsconfig.default.json',
+ },
+ },
};
diff --git a/packages/event/tests/unit/event.test.ts b/packages/event/tests/unit/event.test.ts
index 9867358d..d8e92619 100644
--- a/packages/event/tests/unit/event.test.ts
+++ b/packages/event/tests/unit/event.test.ts
@@ -201,7 +201,7 @@ describe('Event Tests', () => {
describe('disable function tests', () => {
it('should disable Event', () => {
- event.enabled = undefined;
+ event.enabled = undefined as any;
event.disable();
@@ -211,7 +211,7 @@ describe('Event Tests', () => {
describe('enable function tests', () => {
it('should enable Event', () => {
- event.enabled = undefined;
+ event.enabled = undefined as any;
event.enable();
@@ -227,7 +227,7 @@ describe('Event Tests', () => {
// @ts-ignore
// eslint-disable-next-line no-global-assign
clearTimeout = jest.fn();
- event.enabled = undefined;
+ event.enabled = undefined as any;
event.uses = 100;
event.currentTimeout = timeout;
diff --git a/packages/multieditor/jest.config.js b/packages/multieditor/jest.config.js
index a7382750..9852e7e8 100644
--- a/packages/multieditor/jest.config.js
+++ b/packages/multieditor/jest.config.js
@@ -3,5 +3,5 @@ const baseConfig = require('../../jest.config.base');
module.exports = {
...baseConfig,
rootDir: '../..',
- name: 'Multi Editor',
+ name: 'MultiEditor',
};
diff --git a/packages/react/tsconfig.json b/packages/react/tsconfig.json
index 8ecfe483..600cd205 100644
--- a/packages/react/tsconfig.json
+++ b/packages/react/tsconfig.json
@@ -7,5 +7,4 @@
"include": [
"./src/**/*" // Only include what is in src (-> dist, tests, .. will be excluded)
]
-
}
\ No newline at end of file
diff --git a/yarn.lock b/yarn.lock
index 6aa52288..aadeeb94 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3,7 +3,10 @@
"@agile-ts/core@file:packages/core":
- version "0.0.11"
+ version "0.0.12"
+
+"@agile-ts/react@file:packages/react":
+ version "0.0.12"
"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.12.11":
version "7.12.11"
From 1c00c8d2b370638da96d07aa784aff62181d3b8c Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Mon, 29 Mar 2021 18:52:23 +0200
Subject: [PATCH 26/35] fixed jest type errors
---
packages/core/tests/unit/agile.test.ts | 1 -
.../collection/collection.persistent.test.ts | 137 ++++++++++--------
.../tests/unit/collection/collection.test.ts | 26 ++--
.../core/tests/unit/collection/group.test.ts | 28 +++-
.../tests/unit/collection/selector.test.ts | 20 ++-
.../core/tests/unit/computed/computed.test.ts | 2 +-
.../unit/integrations/integrations.test.ts | 2 +-
.../tests/unit/state/state.observer.test.ts | 3 +-
.../tests/unit/state/state.persistent.test.ts | 4 +
packages/core/tests/unit/state/state.test.ts | 20 +--
.../tests/unit/storages/persistent.test.ts | 2 +-
.../core/tests/unit/storages/storage.test.ts | 6 +-
.../core/tests/unit/storages/storages.test.ts | 2 +-
13 files changed, 149 insertions(+), 104 deletions(-)
diff --git a/packages/core/tests/unit/agile.test.ts b/packages/core/tests/unit/agile.test.ts
index ea1089cb..42cb89e0 100644
--- a/packages/core/tests/unit/agile.test.ts
+++ b/packages/core/tests/unit/agile.test.ts
@@ -19,7 +19,6 @@ jest.mock('../../src/integrations/index');
jest.mock('../../src/storages/storage');
jest.mock('../../src/collection/index');
jest.mock('../../src/computed/index');
-jest.mock('../../src/event/index');
/* Can't mock Logger because I somehow can't overwrite a static get method
jest.mock("../../src/logger/index", () => {
return class {
diff --git a/packages/core/tests/unit/collection/collection.persistent.test.ts b/packages/core/tests/unit/collection/collection.persistent.test.ts
index 4a1d74a1..b5710b8f 100644
--- a/packages/core/tests/unit/collection/collection.persistent.test.ts
+++ b/packages/core/tests/unit/collection/collection.persistent.test.ts
@@ -37,6 +37,7 @@ describe('CollectionPersistent Tests', () => {
jest
.spyOn(CollectionPersistent.prototype, 'instantiatePersistent')
.mockImplementationOnce(function () {
+ // @ts-ignore
this.ready = false;
});
@@ -63,6 +64,7 @@ describe('CollectionPersistent Tests', () => {
jest
.spyOn(CollectionPersistent.prototype, 'instantiatePersistent')
.mockImplementationOnce(function () {
+ // @ts-ignore
this.ready = false;
});
@@ -91,6 +93,7 @@ describe('CollectionPersistent Tests', () => {
jest
.spyOn(CollectionPersistent.prototype, 'instantiatePersistent')
.mockImplementationOnce(function () {
+ // @ts-ignore
this.ready = true;
});
@@ -104,6 +107,7 @@ describe('CollectionPersistent Tests', () => {
jest
.spyOn(CollectionPersistent.prototype, 'instantiatePersistent')
.mockImplementationOnce(function () {
+ // @ts-ignore
this.ready = true;
});
@@ -251,19 +255,21 @@ describe('CollectionPersistent Tests', () => {
});
describe('loadPersistedValue function tests', () => {
- let dummyDefaultGroup: Group;
+ let dummyDefaultGroup: Group;
beforeEach(() => {
collectionPersistent.defaultStorageKey = 'test';
dummyDefaultGroup = new Group(dummyCollection, ['1', '2', '3']);
dummyDefaultGroup.persistent = new StatePersistent(dummyDefaultGroup);
- dummyDefaultGroup.persistent.ready = true;
+ if (dummyDefaultGroup.persistent)
+ dummyDefaultGroup.persistent.ready = true;
collectionPersistent.persistValue = jest.fn();
dummyDefaultGroup.persist = jest.fn();
- dummyDefaultGroup.persistent.initialLoading = jest.fn();
+ if (dummyDefaultGroup.persistent)
+ dummyDefaultGroup.persistent.initialLoading = jest.fn();
dummyCollection.collect = jest.fn();
});
@@ -316,7 +322,7 @@ describe('CollectionPersistent Tests', () => {
instantiate: false,
followCollectionPersistKeyPattern: true,
});
- expect(dummyDefaultGroup.persistent.initialLoading).toHaveBeenCalled();
+ expect(dummyDefaultGroup.persistent?.initialLoading).toHaveBeenCalled();
expect(dummyDefaultGroup.isPersisted).toBeTruthy();
expect(dummyCollection.collect).toHaveBeenCalledWith({
@@ -375,7 +381,7 @@ describe('CollectionPersistent Tests', () => {
expect(dummyDefaultGroup.persist).not.toHaveBeenCalled();
expect(
- dummyDefaultGroup.persistent.initialLoading
+ dummyDefaultGroup.persistent?.initialLoading
).not.toHaveBeenCalled();
expect(dummyDefaultGroup.isPersisted).toBeFalsy();
@@ -425,7 +431,7 @@ describe('CollectionPersistent Tests', () => {
instantiate: false,
followCollectionPersistKeyPattern: true,
});
- expect(dummyDefaultGroup.persistent.initialLoading).toHaveBeenCalled();
+ expect(dummyDefaultGroup.persistent?.initialLoading).toHaveBeenCalled();
expect(dummyDefaultGroup.isPersisted).toBeTruthy();
expect(dummyCollection.collect).toHaveBeenCalledWith({
@@ -460,7 +466,7 @@ describe('CollectionPersistent Tests', () => {
expect(dummyDefaultGroup.persist).not.toHaveBeenCalled();
expect(
- dummyDefaultGroup.persistent.initialLoading
+ dummyDefaultGroup.persistent?.initialLoading
).not.toHaveBeenCalled();
expect(dummyDefaultGroup.isPersisted).toBeFalsy();
@@ -513,7 +519,7 @@ describe('CollectionPersistent Tests', () => {
expect(dummyDefaultGroup.persist).not.toHaveBeenCalled();
expect(
- dummyDefaultGroup.persistent.initialLoading
+ dummyDefaultGroup.persistent?.initialLoading
).not.toHaveBeenCalled();
expect(dummyDefaultGroup.isPersisted).toBeFalsy();
@@ -524,11 +530,11 @@ describe('CollectionPersistent Tests', () => {
});
describe('persistValue function tests', () => {
- let dummyDefaultGroup: Group;
+ let dummyDefaultGroup: Group;
beforeEach(() => {
collectionPersistent.storageKeys = ['test1', 'test2'];
- collectionPersistent.isPersisted = undefined;
+ collectionPersistent.isPersisted = undefined as any;
dummyDefaultGroup = new Group(dummyCollection, ['1', '2', '3']);
dummyCollection.data = {
@@ -709,11 +715,11 @@ describe('CollectionPersistent Tests', () => {
});
describe('removePersistedValue function tests', () => {
- let dummyDefaultGroup: Group;
+ let dummyDefaultGroup: Group;
beforeEach(() => {
collectionPersistent.storageKeys = ['test1', 'test2'];
- collectionPersistent.isPersisted = undefined;
+ collectionPersistent.isPersisted = undefined as any;
dummyDefaultGroup = new Group(dummyCollection, ['1', '2', '3']);
dummyDefaultGroup.persistent = new StatePersistent(dummyDefaultGroup);
@@ -722,11 +728,14 @@ describe('CollectionPersistent Tests', () => {
['3']: dummyItem3,
};
- dummyDefaultGroup.persistent.removePersistedValue = jest.fn();
+ if (dummyDefaultGroup.persistent)
+ dummyDefaultGroup.persistent.removePersistedValue = jest.fn();
dummyDefaultGroup.removeSideEffect = jest.fn();
- dummyItem1.persistent.removePersistedValue = jest.fn();
- dummyItem3.persistent.removePersistedValue = jest.fn();
+ if (dummyItem1.persistent)
+ dummyItem1.persistent.removePersistedValue = jest.fn();
+ if (dummyItem3.persistent)
+ dummyItem3.persistent.removePersistedValue = jest.fn();
dummyAgile.storages.remove = jest.fn();
});
@@ -748,14 +757,14 @@ describe('CollectionPersistent Tests', () => {
dummyCollection.config.defaultGroupKey
);
expect(
- dummyDefaultGroup.persistent.removePersistedValue
+ dummyDefaultGroup.persistent?.removePersistedValue
).toHaveBeenCalled();
expect(dummyDefaultGroup.removeSideEffect).toHaveBeenCalledWith(
CollectionPersistent.defaultGroupSideEffectKey
);
- expect(dummyItem1.persistent.removePersistedValue).toHaveBeenCalled();
- expect(dummyItem3.persistent.removePersistedValue).toHaveBeenCalled();
+ expect(dummyItem1.persistent?.removePersistedValue).toHaveBeenCalled();
+ expect(dummyItem3.persistent?.removePersistedValue).toHaveBeenCalled();
expect(collectionPersistent.isPersisted).toBeFalsy();
});
@@ -779,14 +788,14 @@ describe('CollectionPersistent Tests', () => {
dummyCollection.config.defaultGroupKey
);
expect(
- dummyDefaultGroup.persistent.removePersistedValue
+ dummyDefaultGroup.persistent?.removePersistedValue
).toHaveBeenCalled();
expect(dummyDefaultGroup.removeSideEffect).toHaveBeenCalledWith(
CollectionPersistent.defaultGroupSideEffectKey
);
- expect(dummyItem1.persistent.removePersistedValue).toHaveBeenCalled();
- expect(dummyItem3.persistent.removePersistedValue).toHaveBeenCalled();
+ expect(dummyItem1.persistent?.removePersistedValue).toHaveBeenCalled();
+ expect(dummyItem3.persistent?.removePersistedValue).toHaveBeenCalled();
expect(collectionPersistent.isPersisted).toBeFalsy();
});
@@ -803,15 +812,15 @@ describe('CollectionPersistent Tests', () => {
expect(dummyCollection.getGroup).not.toHaveBeenCalled();
expect(
- dummyDefaultGroup.persistent.removePersistedValue
+ dummyDefaultGroup.persistent?.removePersistedValue
).not.toHaveBeenCalled();
expect(dummyDefaultGroup.removeSideEffect).not.toHaveBeenCalled();
expect(
- dummyItem1.persistent.removePersistedValue
+ dummyItem1.persistent?.removePersistedValue
).not.toHaveBeenCalled();
expect(
- dummyItem3.persistent.removePersistedValue
+ dummyItem3.persistent?.removePersistedValue
).not.toHaveBeenCalled();
expect(collectionPersistent.isPersisted).toBeUndefined();
@@ -831,15 +840,15 @@ describe('CollectionPersistent Tests', () => {
dummyCollection.config.defaultGroupKey
);
expect(
- dummyDefaultGroup.persistent.removePersistedValue
+ dummyDefaultGroup.persistent?.removePersistedValue
).not.toHaveBeenCalled();
expect(dummyDefaultGroup.removeSideEffect).not.toHaveBeenCalled();
expect(
- dummyItem1.persistent.removePersistedValue
+ dummyItem1.persistent?.removePersistedValue
).not.toHaveBeenCalled();
expect(
- dummyItem3.persistent.removePersistedValue
+ dummyItem3.persistent?.removePersistedValue
).not.toHaveBeenCalled();
expect(collectionPersistent.isPersisted).toBeUndefined();
@@ -882,7 +891,7 @@ describe('CollectionPersistent Tests', () => {
});
describe('rebuildStorageSideEffects function tests', () => {
- let dummyGroup: Group;
+ let dummyGroup: Group;
beforeEach(() => {
dummyGroup = new Group(dummyCollection);
@@ -899,13 +908,19 @@ describe('CollectionPersistent Tests', () => {
dummyItem3.persist = jest.fn();
dummyItem4WithoutPersistent.persist = jest.fn();
- dummyItem1.persistent.removePersistedValue = jest.fn();
- dummyItem2.persistent.removePersistedValue = jest.fn();
- dummyItem3.persistent.removePersistedValue = jest.fn();
-
- dummyItem1.persistent.persistValue = jest.fn();
- dummyItem2.persistent.persistValue = jest.fn();
- dummyItem3.persistent.persistValue = jest.fn();
+ if (dummyItem1.persistent)
+ dummyItem1.persistent.removePersistedValue = jest.fn();
+ if (dummyItem2.persistent)
+ dummyItem2.persistent.removePersistedValue = jest.fn();
+ if (dummyItem3.persistent)
+ dummyItem3.persistent.removePersistedValue = jest.fn();
+
+ if (dummyItem1.persistent)
+ dummyItem1.persistent.persistValue = jest.fn();
+ if (dummyItem2.persistent)
+ dummyItem2.persistent.persistValue = jest.fn();
+ if (dummyItem3.persistent)
+ dummyItem3.persistent.persistValue = jest.fn();
});
it('should return if no Item got added or removed', () => {
@@ -920,18 +935,18 @@ describe('CollectionPersistent Tests', () => {
expect(dummyItem4WithoutPersistent.persist).not.toHaveBeenCalled();
expect(
- dummyItem1.persistent.removePersistedValue
+ dummyItem1.persistent?.removePersistedValue
).not.toHaveBeenCalled();
expect(
- dummyItem2.persistent.removePersistedValue
+ dummyItem2.persistent?.removePersistedValue
).not.toHaveBeenCalled();
expect(
- dummyItem3.persistent.removePersistedValue
+ dummyItem3.persistent?.removePersistedValue
).not.toHaveBeenCalled();
- expect(dummyItem1.persistent.persistValue).not.toHaveBeenCalled();
- expect(dummyItem2.persistent.persistValue).not.toHaveBeenCalled();
- expect(dummyItem3.persistent.persistValue).not.toHaveBeenCalled();
+ expect(dummyItem1.persistent?.persistValue).not.toHaveBeenCalled();
+ expect(dummyItem2.persistent?.persistValue).not.toHaveBeenCalled();
+ expect(dummyItem3.persistent?.persistValue).not.toHaveBeenCalled();
});
it('should call removePersistedValue on Items that got removed from Group', () => {
@@ -945,19 +960,23 @@ describe('CollectionPersistent Tests', () => {
expect(dummyItem3.persist).not.toHaveBeenCalled();
expect(dummyItem4WithoutPersistent.persist).not.toHaveBeenCalled();
- expect(dummyItem1.persistent.removePersistedValue).toHaveBeenCalledWith(
+ expect(
+ dummyItem1.persistent?.removePersistedValue
+ ).toHaveBeenCalledWith(
CollectionPersistent.getItemStorageKey('1', collectionPersistent._key)
);
expect(
- dummyItem2.persistent.removePersistedValue
+ dummyItem2.persistent?.removePersistedValue
).not.toHaveBeenCalled();
- expect(dummyItem3.persistent.removePersistedValue).toHaveBeenCalledWith(
+ expect(
+ dummyItem3.persistent?.removePersistedValue
+ ).toHaveBeenCalledWith(
CollectionPersistent.getItemStorageKey('3', collectionPersistent._key)
);
- expect(dummyItem1.persistent.persistValue).not.toHaveBeenCalled();
- expect(dummyItem2.persistent.persistValue).not.toHaveBeenCalled();
- expect(dummyItem3.persistent.persistValue).not.toHaveBeenCalled();
+ expect(dummyItem1.persistent?.persistValue).not.toHaveBeenCalled();
+ expect(dummyItem2.persistent?.persistValue).not.toHaveBeenCalled();
+ expect(dummyItem3.persistent?.persistValue).not.toHaveBeenCalled();
});
it('should call persistValue on Items that have a persistent and got added to Group', () => {
@@ -972,20 +991,20 @@ describe('CollectionPersistent Tests', () => {
expect(dummyItem4WithoutPersistent.persist).not.toHaveBeenCalled();
expect(
- dummyItem1.persistent.removePersistedValue
+ dummyItem1.persistent?.removePersistedValue
).not.toHaveBeenCalled();
expect(
- dummyItem2.persistent.removePersistedValue
+ dummyItem2.persistent?.removePersistedValue
).not.toHaveBeenCalled();
expect(
- dummyItem3.persistent.removePersistedValue
+ dummyItem3.persistent?.removePersistedValue
).not.toHaveBeenCalled();
- expect(dummyItem1.persistent.persistValue).not.toHaveBeenCalled();
- expect(dummyItem2.persistent.persistValue).toHaveBeenCalledWith(
+ expect(dummyItem1.persistent?.persistValue).not.toHaveBeenCalled();
+ expect(dummyItem2.persistent?.persistValue).toHaveBeenCalledWith(
CollectionPersistent.getItemStorageKey('2', collectionPersistent._key)
);
- expect(dummyItem3.persistent.persistValue).toHaveBeenCalledWith(
+ expect(dummyItem3.persistent?.persistValue).toHaveBeenCalledWith(
CollectionPersistent.getItemStorageKey('3', collectionPersistent._key)
);
});
@@ -1004,18 +1023,18 @@ describe('CollectionPersistent Tests', () => {
);
expect(
- dummyItem1.persistent.removePersistedValue
+ dummyItem1.persistent?.removePersistedValue
).not.toHaveBeenCalled();
expect(
- dummyItem2.persistent.removePersistedValue
+ dummyItem2.persistent?.removePersistedValue
).not.toHaveBeenCalled();
expect(
- dummyItem3.persistent.removePersistedValue
+ dummyItem3.persistent?.removePersistedValue
).not.toHaveBeenCalled();
- expect(dummyItem1.persistent.persistValue).not.toHaveBeenCalled();
- expect(dummyItem2.persistent.persistValue).not.toHaveBeenCalled();
- expect(dummyItem3.persistent.persistValue).not.toHaveBeenCalled();
+ expect(dummyItem1.persistent?.persistValue).not.toHaveBeenCalled();
+ expect(dummyItem2.persistent?.persistValue).not.toHaveBeenCalled();
+ expect(dummyItem3.persistent?.persistValue).not.toHaveBeenCalled();
});
});
diff --git a/packages/core/tests/unit/collection/collection.test.ts b/packages/core/tests/unit/collection/collection.test.ts
index 46bade21..1390ef7c 100644
--- a/packages/core/tests/unit/collection/collection.test.ts
+++ b/packages/core/tests/unit/collection/collection.test.ts
@@ -67,7 +67,9 @@ describe('Collection Tests', () => {
jest
.spyOn(Collection.prototype, 'initGroups')
.mockReturnValueOnce(undefined);
- jest.spyOn(Collection.prototype, 'collect').mockReturnValueOnce(undefined);
+ jest
+ .spyOn(Collection.prototype, 'collect')
+ .mockReturnValueOnce(undefined as any);
const collection = new Collection(dummyAgile, {
defaultGroupKey: 'general',
@@ -111,7 +113,9 @@ describe('Collection Tests', () => {
jest
.spyOn(Collection.prototype, 'initGroups')
.mockReturnValueOnce(undefined);
- jest.spyOn(Collection.prototype, 'collect').mockReturnValueOnce(undefined);
+ jest
+ .spyOn(Collection.prototype, 'collect')
+ .mockReturnValueOnce(undefined as any);
const collection = new Collection(
dummyAgile,
@@ -183,30 +187,30 @@ describe('Collection Tests', () => {
});
it('should update existing Key in all instances', () => {
- collection.persistent._key = 'collectionKey';
+ if (collection.persistent) collection.persistent._key = 'collectionKey';
collection.setKey('newKey');
expect(collection._key).toBe('newKey');
- expect(collection.persistent.setKey).toHaveBeenCalledWith('newKey');
+ expect(collection.persistent?.setKey).toHaveBeenCalledWith('newKey');
});
it("should update existing Key in all instances except persistent if the CollectionKey and PersistKey aren't equal", () => {
- collection.persistent._key = 'randomKey';
+ if (collection.persistent) collection.persistent._key = 'randomKey';
collection.setKey('newKey');
expect(collection._key).toBe('newKey');
- expect(collection.persistent.setKey).not.toHaveBeenCalled();
+ expect(collection.persistent?.setKey).not.toHaveBeenCalled();
});
it('should update existing Key in all instances except persistent if new CollectionKey is undefined', () => {
- collection.persistent._key = 'collectionKey';
+ if (collection.persistent) collection.persistent._key = 'collectionKey';
collection.setKey(undefined);
expect(collection._key).toBeUndefined();
- expect(collection.persistent.setKey).not.toHaveBeenCalled();
+ expect(collection.persistent?.setKey).not.toHaveBeenCalled();
});
});
@@ -448,9 +452,9 @@ describe('Collection Tests', () => {
});
describe('collect function tests', () => {
- let dummyGroup1: Group;
- let dummyGroup2: Group;
- let defaultGroup: Group;
+ let dummyGroup1: Group;
+ let dummyGroup2: Group;
+ let defaultGroup: Group;
beforeEach(() => {
dummyGroup1 = new Group(collection);
diff --git a/packages/core/tests/unit/collection/group.test.ts b/packages/core/tests/unit/collection/group.test.ts
index 689f0ad2..75f95a69 100644
--- a/packages/core/tests/unit/collection/group.test.ts
+++ b/packages/core/tests/unit/collection/group.test.ts
@@ -34,8 +34,12 @@ describe('Group Tests', () => {
it('should create Group with no initialItems (default config)', () => {
// Overwrite methods once to not call it
- jest.spyOn(Group.prototype, 'rebuild').mockReturnValueOnce(undefined);
- jest.spyOn(Group.prototype, 'addSideEffect').mockReturnValueOnce(undefined);
+ jest
+ .spyOn(Group.prototype, 'rebuild')
+ .mockReturnValueOnce(undefined as any);
+ jest
+ .spyOn(Group.prototype, 'addSideEffect')
+ .mockReturnValueOnce(undefined as any);
const group = new Group(dummyCollection);
@@ -65,8 +69,12 @@ describe('Group Tests', () => {
it('should create Group with no initialItems (specific config)', () => {
// Overwrite methods once to not call it
- jest.spyOn(Group.prototype, 'rebuild').mockReturnValueOnce(undefined);
- jest.spyOn(Group.prototype, 'addSideEffect').mockReturnValueOnce(undefined);
+ jest
+ .spyOn(Group.prototype, 'rebuild')
+ .mockReturnValueOnce(undefined as any);
+ jest
+ .spyOn(Group.prototype, 'addSideEffect')
+ .mockReturnValueOnce(undefined as any);
const group = new Group(dummyCollection, [], {
key: 'dummyKey',
@@ -99,8 +107,12 @@ describe('Group Tests', () => {
it('should create Group with initialItems (default config)', () => {
// Overwrite methods once to not call it
- jest.spyOn(Group.prototype, 'rebuild').mockReturnValueOnce(undefined);
- jest.spyOn(Group.prototype, 'addSideEffect').mockReturnValueOnce(undefined);
+ jest
+ .spyOn(Group.prototype, 'rebuild')
+ .mockReturnValueOnce(undefined as any);
+ jest
+ .spyOn(Group.prototype, 'addSideEffect')
+ .mockReturnValueOnce(undefined as any);
const group = new Group(dummyCollection, ['test1', 'test2', 'test3']);
@@ -140,8 +152,8 @@ describe('Group Tests', () => {
});
dummyCollection.collect({ id: 'dummyItem1Key', name: 'coolName' });
dummyCollection.collect({ id: 'dummyItem2Key', name: 'coolName' });
- dummyItem1 = dummyCollection.getItem('dummyItem1Key');
- dummyItem2 = dummyCollection.getItem('dummyItem2Key');
+ dummyItem1 = dummyCollection.getItem('dummyItem1Key') as any;
+ dummyItem2 = dummyCollection.getItem('dummyItem2Key') as any;
dummyItem3 = new Item(dummyCollection, {
id: 'dummyItem3Key',
name: 'coolName',
diff --git a/packages/core/tests/unit/collection/selector.test.ts b/packages/core/tests/unit/collection/selector.test.ts
index d318d30f..78fa2c44 100644
--- a/packages/core/tests/unit/collection/selector.test.ts
+++ b/packages/core/tests/unit/collection/selector.test.ts
@@ -20,7 +20,9 @@ describe('Selector Tests', () => {
it('should create Selector and call initial select (default config)', () => {
// Overwrite select once to not call it
- jest.spyOn(Selector.prototype, 'select').mockReturnValueOnce(undefined);
+ jest
+ .spyOn(Selector.prototype, 'select')
+ .mockReturnValueOnce(undefined as any);
const selector = new Selector(dummyCollection, 'dummyItemKey');
@@ -52,7 +54,9 @@ describe('Selector Tests', () => {
it('should create Selector and call initial select (specific config)', () => {
// Overwrite select once to not call it
- jest.spyOn(Selector.prototype, 'select').mockReturnValueOnce(undefined);
+ jest
+ .spyOn(Selector.prototype, 'select')
+ .mockReturnValueOnce(undefined as any);
const selector = new Selector(dummyCollection, 'dummyItemKey', {
key: 'dummyKey',
@@ -86,7 +90,9 @@ describe('Selector Tests', () => {
it("should create Selector and shouldn't call initial select (config.isPlaceholder = true)", () => {
// Overwrite select once to not call it
- jest.spyOn(Selector.prototype, 'select').mockReturnValueOnce(undefined);
+ jest
+ .spyOn(Selector.prototype, 'select')
+ .mockReturnValueOnce(undefined as any);
const selector = new Selector(dummyCollection, 'dummyItemKey', {
isPlaceholder: true,
@@ -535,25 +541,25 @@ describe('Selector Tests', () => {
});
it('should return true if Selector has selected ItemKey and Item isSelected', () => {
- selector.item.isSelected = true;
+ if (selector.item) selector.item.isSelected = true;
expect(selector.hasSelected('dummyItemKey')).toBeTruthy();
});
it("should return false if Selector hasn't selected ItemKey and Item isSelected", () => {
- selector.item.isSelected = true;
+ if (selector.item) selector.item.isSelected = true;
expect(selector.hasSelected('notSelectedItemKey')).toBeFalsy();
});
it("should return false if Selector has selected ItemKey and Item isn't isSelected", () => {
- selector.item.isSelected = false;
+ if (selector.item) selector.item.isSelected = false;
expect(selector.hasSelected('dummyItemKey')).toBeFalsy();
});
it("should return false if Selector hasn't selected ItemKey and Item isn't isSelected", () => {
- selector.item.isSelected = false;
+ if (selector.item) selector.item.isSelected = false;
expect(selector.hasSelected('notSelectedItemKey')).toBeFalsy();
});
diff --git a/packages/core/tests/unit/computed/computed.test.ts b/packages/core/tests/unit/computed/computed.test.ts
index 1cb5eb62..71a822fa 100644
--- a/packages/core/tests/unit/computed/computed.test.ts
+++ b/packages/core/tests/unit/computed/computed.test.ts
@@ -57,7 +57,7 @@ describe('Computed Tests', () => {
const computed = new Computed(dummyAgile, computedFunction, {
key: 'coolComputed',
dependents: [dummyObserver1],
- computedDeps: [dummyObserver2, undefined, dummyState],
+ computedDeps: [dummyObserver2, undefined as any, dummyState],
});
expect(computed.computeFunction).toBe(computedFunction);
diff --git a/packages/core/tests/unit/integrations/integrations.test.ts b/packages/core/tests/unit/integrations/integrations.test.ts
index a22ee088..660ed3f9 100644
--- a/packages/core/tests/unit/integrations/integrations.test.ts
+++ b/packages/core/tests/unit/integrations/integrations.test.ts
@@ -88,7 +88,7 @@ describe('Integrations Tests', () => {
});
it("shouldn't integrate Integration that has no valid Key", async () => {
- dummyIntegration1._key = undefined;
+ dummyIntegration1._key = undefined as any;
const response = await integrations.integrate(dummyIntegration1);
diff --git a/packages/core/tests/unit/state/state.observer.test.ts b/packages/core/tests/unit/state/state.observer.test.ts
index ebfc1c09..422c8fe5 100644
--- a/packages/core/tests/unit/state/state.observer.test.ts
+++ b/packages/core/tests/unit/state/state.observer.test.ts
@@ -351,8 +351,7 @@ describe('StateObserver Tests', () => {
describe('sideEffects function tests', () => {
let dummyJob: StateRuntimeJob;
- let dummyStateObserver: StateObserver;
- let sideEffectCallOrder = [];
+ let sideEffectCallOrder: string[] = [];
beforeEach(() => {
sideEffectCallOrder = [];
diff --git a/packages/core/tests/unit/state/state.persistent.test.ts b/packages/core/tests/unit/state/state.persistent.test.ts
index ea3d5f66..1c3780ad 100644
--- a/packages/core/tests/unit/state/state.persistent.test.ts
+++ b/packages/core/tests/unit/state/state.persistent.test.ts
@@ -26,6 +26,7 @@ describe('StatePersistent Tests', () => {
jest
.spyOn(StatePersistent.prototype, 'instantiatePersistent')
.mockImplementationOnce(function () {
+ //@ts-ignore
this.ready = false;
});
@@ -52,6 +53,7 @@ describe('StatePersistent Tests', () => {
jest
.spyOn(StatePersistent.prototype, 'instantiatePersistent')
.mockImplementationOnce(function () {
+ // @ts-ignore
this.ready = false;
});
@@ -80,6 +82,7 @@ describe('StatePersistent Tests', () => {
jest
.spyOn(StatePersistent.prototype, 'instantiatePersistent')
.mockImplementationOnce(function () {
+ // @ts-ignore
this.ready = true;
});
@@ -93,6 +96,7 @@ describe('StatePersistent Tests', () => {
jest
.spyOn(StatePersistent.prototype, 'instantiatePersistent')
.mockImplementationOnce(function () {
+ // @ts-ignore
this.ready = true;
});
diff --git a/packages/core/tests/unit/state/state.test.ts b/packages/core/tests/unit/state/state.test.ts
index 58731002..6fcb651a 100644
--- a/packages/core/tests/unit/state/state.test.ts
+++ b/packages/core/tests/unit/state/state.test.ts
@@ -25,7 +25,7 @@ describe('State Tests', () => {
it('should create State and should call initial set (default config)', () => {
// Overwrite select once to not call it
- jest.spyOn(State.prototype, 'set').mockReturnValueOnce(undefined);
+ jest.spyOn(State.prototype, 'set').mockReturnValueOnce(undefined as any);
const state = new State(dummyAgile, 'coolValue');
@@ -51,7 +51,7 @@ describe('State Tests', () => {
it('should create State and should call initial set (specific config)', () => {
// Overwrite select once to not call it
- jest.spyOn(State.prototype, 'set').mockReturnValueOnce(undefined);
+ jest.spyOn(State.prototype, 'set').mockReturnValueOnce(undefined as any);
const dummyObserver = new Observer(dummyAgile);
@@ -83,7 +83,7 @@ describe('State Tests', () => {
it("should create State and shouldn't call initial set (config.isPlaceholder = true)", () => {
// Overwrite select once to not call it
- jest.spyOn(State.prototype, 'set').mockReturnValueOnce(undefined);
+ jest.spyOn(State.prototype, 'set').mockReturnValueOnce(undefined as any);
const state = new State(dummyAgile, 'coolValue', { isPlaceholder: true });
@@ -182,33 +182,35 @@ describe('State Tests', () => {
});
it('should update existing Key in all instances', () => {
- numberState.persistent._key = 'numberStateKey';
+ if (numberState.persistent)
+ numberState.persistent._key = 'numberStateKey';
numberState.setKey('newKey');
expect(numberState._key).toBe('newKey');
expect(numberState.observer._key).toBe('newKey');
- expect(numberState.persistent.setKey).toHaveBeenCalledWith('newKey');
+ expect(numberState.persistent?.setKey).toHaveBeenCalledWith('newKey');
});
it("should update existing Key in all instances except persistent if the StateKey and PersistKey aren't equal", () => {
- numberState.persistent._key = 'randomKey';
+ if (numberState.persistent) numberState.persistent._key = 'randomKey';
numberState.setKey('newKey');
expect(numberState._key).toBe('newKey');
expect(numberState.observer._key).toBe('newKey');
- expect(numberState.persistent.setKey).not.toHaveBeenCalled();
+ expect(numberState.persistent?.setKey).not.toHaveBeenCalled();
});
it('should update existing Key in all instances except persistent if new StateKey is undefined', () => {
- numberState.persistent._key = 'numberStateKey';
+ if (numberState.persistent)
+ numberState.persistent._key = 'numberStateKey';
numberState.setKey(undefined);
expect(numberState._key).toBeUndefined();
expect(numberState.observer._key).toBeUndefined();
- expect(numberState.persistent.setKey).not.toHaveBeenCalled();
+ expect(numberState.persistent?.setKey).not.toHaveBeenCalled();
});
});
diff --git a/packages/core/tests/unit/storages/persistent.test.ts b/packages/core/tests/unit/storages/persistent.test.ts
index 39a11a4d..998e109a 100644
--- a/packages/core/tests/unit/storages/persistent.test.ts
+++ b/packages/core/tests/unit/storages/persistent.test.ts
@@ -139,7 +139,7 @@ describe('Persistent Tests', () => {
persistent.key = Persistent.placeHolderKey;
persistent.defaultStorageKey = undefined;
persistent.storageKeys = [];
- persistent.ready = undefined;
+ persistent.ready = undefined as any;
});
it('should return false and print error if no set key and no set StorageKeys', () => {
diff --git a/packages/core/tests/unit/storages/storage.test.ts b/packages/core/tests/unit/storages/storage.test.ts
index 9cf1d7af..c13e2819 100644
--- a/packages/core/tests/unit/storages/storage.test.ts
+++ b/packages/core/tests/unit/storages/storage.test.ts
@@ -129,7 +129,7 @@ describe('Storage Tests', () => {
});
it("should return false if get method isn't valid", () => {
- storage.methods.get = undefined;
+ storage.methods.get = undefined as any;
const response = storage.validate();
@@ -140,7 +140,7 @@ describe('Storage Tests', () => {
});
it("should return false if set method isn't valid", () => {
- storage.methods.set = undefined;
+ storage.methods.set = undefined as any;
const response = storage.validate();
@@ -151,7 +151,7 @@ describe('Storage Tests', () => {
});
it("should return false if remove method isn't valid", () => {
- storage.methods.remove = undefined;
+ storage.methods.remove = undefined as any;
const response = storage.validate();
diff --git a/packages/core/tests/unit/storages/storages.test.ts b/packages/core/tests/unit/storages/storages.test.ts
index b6adc84a..aad3e4cb 100644
--- a/packages/core/tests/unit/storages/storages.test.ts
+++ b/packages/core/tests/unit/storages/storages.test.ts
@@ -382,7 +382,7 @@ describe('Storages Tests', () => {
});
it('should return false if no instance of localStorage exits', () => {
- global.localStorage = undefined;
+ global.localStorage = undefined as any;
expect(Storages.localStorageAvailable()).toBeFalsy();
});
From 5a0c46746994603b406eb9fb0f42425fba33c20f Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Mon, 29 Mar 2021 19:58:01 +0200
Subject: [PATCH 27/35] fixed jest type errors
---
.../tests/unit/collection/collection.test.ts | 79 ++++++++++---------
packages/event/tests/unit/event.test.ts | 2 +-
2 files changed, 41 insertions(+), 40 deletions(-)
diff --git a/packages/core/tests/unit/collection/collection.test.ts b/packages/core/tests/unit/collection/collection.test.ts
index 1390ef7c..a1044b07 100644
--- a/packages/core/tests/unit/collection/collection.test.ts
+++ b/packages/core/tests/unit/collection/collection.test.ts
@@ -627,6 +627,7 @@ describe('Collection Tests', () => {
notExistingGroup.add = jest.fn();
collection.setData = jest.fn(() => true);
collection.createGroup = jest.fn(function (groupKey) {
+ //@ts-ignore
this.groups[groupKey] = notExistingGroup;
return notExistingGroup as any;
});
@@ -901,7 +902,7 @@ describe('Collection Tests', () => {
});
describe('createGroup function tests', () => {
- let dummyGroup: Group;
+ let dummyGroup: Group;
let dummyItem: Item;
beforeEach(() => {
@@ -955,7 +956,7 @@ describe('Collection Tests', () => {
});
describe('hasGroup function tests', () => {
- let dummyGroup: Group;
+ let dummyGroup: Group;
beforeEach(() => {
dummyGroup = new Group(collection, []);
@@ -994,7 +995,7 @@ describe('Collection Tests', () => {
});
describe('getGroup function tests', () => {
- let dummyGroup: Group;
+ let dummyGroup: Group;
beforeEach(() => {
dummyGroup = new Group(collection, [], { key: 'dummyGroup' });
@@ -1045,7 +1046,7 @@ describe('Collection Tests', () => {
});
describe('getGroupWithReference function tests', () => {
- let dummyGroup: Group;
+ let dummyGroup: Group;
beforeEach(() => {
dummyGroup = new Group(collection, [], { key: 'dummyGroup' });
@@ -1077,7 +1078,7 @@ describe('Collection Tests', () => {
});
describe('removeGroup function tests', () => {
- let dummyGroup: Group;
+ let dummyGroup: Group;
beforeEach(() => {
dummyGroup = new Group(collection, [], { key: 'dummyGroup' });
@@ -1103,7 +1104,7 @@ describe('Collection Tests', () => {
});
describe('createSelector function tests', () => {
- let dummySelector: Selector;
+ let dummySelector: Selector;
let dummyItem: Item;
beforeEach(() => {
@@ -1165,7 +1166,7 @@ describe('Collection Tests', () => {
});
describe('hasSelector function tests', () => {
- let dummySelector: Selector;
+ let dummySelector: Selector;
beforeEach(() => {
dummySelector = new Selector(collection, 'unknown');
@@ -1204,7 +1205,7 @@ describe('Collection Tests', () => {
});
describe('getSelector function tests', () => {
- let dummySelector: Selector;
+ let dummySelector: Selector;
beforeEach(() => {
dummySelector = new Selector(collection, 'dummyItem', {
@@ -1257,7 +1258,7 @@ describe('Collection Tests', () => {
});
describe('getSelectorWithReference function tests', () => {
- let dummySelector: Selector;
+ let dummySelector: Selector;
beforeEach(() => {
dummySelector = new Selector(collection, 'dummyItem', {
@@ -1293,7 +1294,7 @@ describe('Collection Tests', () => {
});
describe('removeSelector function tests', () => {
- let dummySelector: Selector;
+ let dummySelector: Selector;
beforeEach(() => {
dummySelector = new Selector(collection, 'dummyItem', {
@@ -1708,8 +1709,8 @@ describe('Collection Tests', () => {
});
describe('reset function tests', () => {
- let dummyGroup: Group;
- let dummySelector: Selector;
+ let dummyGroup: Group;
+ let dummySelector: Selector;
let dummyItem: Item;
beforeEach(() => {
@@ -1743,8 +1744,8 @@ describe('Collection Tests', () => {
});
describe('put function tests', () => {
- let dummyGroup1: Group;
- let dummyGroup2: Group;
+ let dummyGroup1: Group;
+ let dummyGroup2: Group;
beforeEach(() => {
dummyGroup1 = new Group(collection, [], { key: 'dummyGroup1' });
@@ -1790,11 +1791,11 @@ describe('Collection Tests', () => {
});
describe('updateItemKey function tests', () => {
- let dummySelector1: Selector;
- let dummySelector2: Selector;
- let dummySelector3: Selector;
- let dummyGroup1: Group;
- let dummyGroup2: Group;
+ let dummySelector1: Selector;
+ let dummySelector2: Selector;
+ let dummySelector3: Selector;
+ let dummyGroup1: Group;
+ let dummyGroup2: Group;
let dummyItem1: Item;
let dummyItem2: Item;
@@ -1856,13 +1857,13 @@ describe('Collection Tests', () => {
background: false,
});
expect(dummyItem2.setKey).not.toHaveBeenCalled();
- expect(dummyItem1.persistent.setKey).toHaveBeenCalledWith(
+ expect(dummyItem1.persistent?.setKey).toHaveBeenCalledWith(
CollectionPersistent.getItemStorageKey(
'newDummyItem',
collection._key
)
);
- expect(dummyItem2.persistent.setKey).not.toHaveBeenCalled();
+ expect(dummyItem2.persistent?.setKey).not.toHaveBeenCalled();
expect(dummyGroup1.replace).toHaveBeenCalledWith(
'dummyItem1',
@@ -1897,7 +1898,7 @@ describe('Collection Tests', () => {
expect(dummyItem1.setKey).toHaveBeenCalledWith('newDummyItem', {
background: true,
});
- expect(dummyItem1.persistent.setKey).toHaveBeenCalledWith(
+ expect(dummyItem1.persistent?.setKey).toHaveBeenCalledWith(
CollectionPersistent.getItemStorageKey(
'newDummyItem',
collection._key
@@ -1932,7 +1933,7 @@ describe('Collection Tests', () => {
expect(dummyItem1.setKey).toHaveBeenCalledWith('newDummyItem', {
background: false,
});
- expect(dummyItem1.persistent.setKey).toHaveBeenCalledWith(
+ expect(dummyItem1.persistent?.setKey).toHaveBeenCalledWith(
CollectionPersistent.getItemStorageKey(
'newDummyItem',
collection._key
@@ -1982,9 +1983,9 @@ describe('Collection Tests', () => {
});
describe('getGroupKeysThatHaveItemKey function tests', () => {
- let dummyGroup1: Group;
- let dummyGroup2: Group;
- let dummyGroup3: Group;
+ let dummyGroup1: Group;
+ let dummyGroup2: Group;
+ let dummyGroup3: Group;
beforeEach(() => {
dummyGroup1 = new Group(
@@ -2050,9 +2051,9 @@ describe('Collection Tests', () => {
});
describe('removeFromGroups function tests', () => {
- let dummyGroup1: Group;
- let dummyGroup2: Group;
- let dummyGroup3: Group;
+ let dummyGroup1: Group;
+ let dummyGroup2: Group;
+ let dummyGroup3: Group;
beforeEach(() => {
dummyGroup1 = new Group(
@@ -2120,10 +2121,10 @@ describe('Collection Tests', () => {
});
describe('removeItems function test', () => {
- let dummySelector1: Selector;
- let dummySelector2: Selector;
- let dummyGroup1: Group;
- let dummyGroup2: Group;
+ let dummySelector1: Selector;
+ let dummySelector2: Selector;
+ let dummyGroup1: Group;
+ let dummyGroup2: Group;
let dummyItem1: Item;
let dummyItem2: Item;
@@ -2177,9 +2178,9 @@ describe('Collection Tests', () => {
expect(collection.data).toHaveProperty('dummyItem2');
expect(collection.size).toBe(1);
- expect(dummyItem1.persistent.removePersistedValue).toHaveBeenCalled();
+ expect(dummyItem1.persistent?.removePersistedValue).toHaveBeenCalled();
expect(
- dummyItem2.persistent.removePersistedValue
+ dummyItem2.persistent?.removePersistedValue
).not.toHaveBeenCalled();
expect(dummyGroup1.remove).toHaveBeenCalledWith('dummyItem1');
@@ -2198,8 +2199,8 @@ describe('Collection Tests', () => {
expect(collection.data).not.toHaveProperty('dummyItem2');
expect(collection.size).toBe(0);
- expect(dummyItem1.persistent.removePersistedValue).toHaveBeenCalled();
- expect(dummyItem2.persistent.removePersistedValue).toHaveBeenCalled();
+ expect(dummyItem1.persistent?.removePersistedValue).toHaveBeenCalled();
+ expect(dummyItem2.persistent?.removePersistedValue).toHaveBeenCalled();
expect(dummyGroup1.remove).toHaveBeenCalledWith('dummyItem1');
expect(dummyGroup1.remove).toHaveBeenCalledWith('dummyItem2');
@@ -2351,8 +2352,8 @@ describe('Collection Tests', () => {
});
describe('rebuildGroupsThatIncludeItemKey function tests', () => {
- let dummyGroup1: Group;
- let dummyGroup2: Group;
+ let dummyGroup1: Group;
+ let dummyGroup2: Group;
beforeEach(() => {
dummyGroup1 = new Group(collection, ['dummyItem1', 'dummyItem2'], {
diff --git a/packages/event/tests/unit/event.test.ts b/packages/event/tests/unit/event.test.ts
index d8e92619..702b5db8 100644
--- a/packages/event/tests/unit/event.test.ts
+++ b/packages/event/tests/unit/event.test.ts
@@ -1,6 +1,6 @@
import { Event, EventObserver } from '../../src';
import { Agile, Observer } from '@agile-ts/core';
-import * as Utils from '@agile-ts/core';
+import * as Utils from '@agile-ts/core/src/utils';
describe('Event Tests', () => {
let dummyAgile: Agile;
From 049840b8198121ed59ad786cbf4e3bdc2d64ff3d Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Mon, 29 Mar 2021 20:07:45 +0200
Subject: [PATCH 28/35] fixed typeerror and create useEvent
---
packages/event/package.json | 9 +++++++--
packages/{react => event}/src/hooks/useEvent.ts | 5 ++---
packages/event/src/index.ts | 1 +
packages/event/tests/unit/event.test.ts | 2 +-
packages/react/src/hooks/useAgile.ts | 2 +-
.../src/{utils => hooks}/useIsomorphicLayoutEffect.ts | 0
packages/react/src/index.ts | 2 +-
7 files changed, 13 insertions(+), 8 deletions(-)
rename packages/{react => event}/src/hooks/useEvent.ts (90%)
rename packages/react/src/{utils => hooks}/useIsomorphicLayoutEffect.ts (100%)
diff --git a/packages/event/package.json b/packages/event/package.json
index 3e3e6b28..c4e3f44e 100644
--- a/packages/event/package.json
+++ b/packages/event/package.json
@@ -23,10 +23,15 @@
"preview": "npm pack"
},
"devDependencies": {
- "@agile-ts/core": "file:../core"
+ "@agile-ts/core": "file:../core",
+ "@agile-ts/react": "file:../react",
+ "@types/react": "^17.0.0",
+ "react": "^17.0.1"
},
"peerDependencies": {
- "@agile-ts/core": "^0.0.12"
+ "react": "^16.13.1",
+ "@agile-ts/core": "^0.0.12",
+ "@agile-ts/react": "^0.0.12"
},
"publishConfig": {
"access": "public"
diff --git a/packages/react/src/hooks/useEvent.ts b/packages/event/src/hooks/useEvent.ts
similarity index 90%
rename from packages/react/src/hooks/useEvent.ts
rename to packages/event/src/hooks/useEvent.ts
index 895eca97..6aef1f5c 100644
--- a/packages/react/src/hooks/useEvent.ts
+++ b/packages/event/src/hooks/useEvent.ts
@@ -1,12 +1,11 @@
import React from 'react';
import {
Agile,
- Event,
- EventCallbackFunction,
getAgileInstance,
SubscriptionContainerKeyType,
} from '@agile-ts/core';
-import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect';
+import { Event, EventCallbackFunction } from '../internal';
+import { useIsomorphicLayoutEffect } from '@agile-ts/react';
export function useEvent>(
event: E,
diff --git a/packages/event/src/index.ts b/packages/event/src/index.ts
index 3cb08d20..f3396fb7 100644
--- a/packages/event/src/index.ts
+++ b/packages/event/src/index.ts
@@ -1,4 +1,5 @@
import { Event } from './internal';
export * from './internal';
+export { useEvent } from './hooks/useEvent';
export default Event;
diff --git a/packages/event/tests/unit/event.test.ts b/packages/event/tests/unit/event.test.ts
index 702b5db8..3800cc63 100644
--- a/packages/event/tests/unit/event.test.ts
+++ b/packages/event/tests/unit/event.test.ts
@@ -1,6 +1,6 @@
import { Event, EventObserver } from '../../src';
import { Agile, Observer } from '@agile-ts/core';
-import * as Utils from '@agile-ts/core/src/utils';
+import * as Utils from '@agile-ts/core/dist/utils';
describe('Event Tests', () => {
let dummyAgile: Agile;
diff --git a/packages/react/src/hooks/useAgile.ts b/packages/react/src/hooks/useAgile.ts
index 6c4947e6..31ca823a 100644
--- a/packages/react/src/hooks/useAgile.ts
+++ b/packages/react/src/hooks/useAgile.ts
@@ -9,7 +9,7 @@ import {
State,
SubscriptionContainerKeyType,
} from '@agile-ts/core';
-import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect';
+import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';
//=========================================================================================================
// useAgile
diff --git a/packages/react/src/utils/useIsomorphicLayoutEffect.ts b/packages/react/src/hooks/useIsomorphicLayoutEffect.ts
similarity index 100%
rename from packages/react/src/utils/useIsomorphicLayoutEffect.ts
rename to packages/react/src/hooks/useIsomorphicLayoutEffect.ts
diff --git a/packages/react/src/index.ts b/packages/react/src/index.ts
index 2a14fc56..ac70be1f 100644
--- a/packages/react/src/index.ts
+++ b/packages/react/src/index.ts
@@ -2,7 +2,7 @@ import reactIntegration from './react.integration';
export { useAgile } from './hooks/useAgile';
export { AgileHOC } from './other/AgileHOC';
-export { useEvent } from './hooks/useEvent';
export { useWatcher } from './hooks/useWatcher';
+export { useIsomorphicLayoutEffect } from './hooks/useIsomorphicLayoutEffect';
export default reactIntegration;
From 4f5deedf42a2653f4c46e858157b49f0b6d6418c Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Mon, 29 Mar 2021 20:33:19 +0200
Subject: [PATCH 29/35] fixed examples
---
examples/react-native/AwesomeTSProject/core/index.ts | 3 ++-
examples/react-native/AwesomeTSProject/package.json | 1 +
examples/react/functional-component-ts/src/App.tsx | 3 ++-
package.json | 4 +++-
4 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/examples/react-native/AwesomeTSProject/core/index.ts b/examples/react-native/AwesomeTSProject/core/index.ts
index 3e5f1e2c..011ceb0e 100644
--- a/examples/react-native/AwesomeTSProject/core/index.ts
+++ b/examples/react-native/AwesomeTSProject/core/index.ts
@@ -1,4 +1,5 @@
import { Agile } from '@agile-ts/core';
+import { Event } from '@agile-ts/event';
import { Alert } from 'react-native';
export const App = new Agile({
@@ -42,7 +43,7 @@ MY_COLLECTION.getGroup('myGroup')?.persist({
console.log('Initial: myCollection ', MY_COLLECTION);
-export const MY_EVENT = App.createEvent<{ name: string }>();
+export const MY_EVENT = new Event<{ name: string }>(App);
MY_EVENT.on('Test', (payload) => {
Alert.alert(
diff --git a/examples/react-native/AwesomeTSProject/package.json b/examples/react-native/AwesomeTSProject/package.json
index e41e5b67..70fffb4f 100644
--- a/examples/react-native/AwesomeTSProject/package.json
+++ b/examples/react-native/AwesomeTSProject/package.json
@@ -14,6 +14,7 @@
"@agile-ts/api": "file:.yalc/@agile-ts/api",
"@agile-ts/core": "file:.yalc/@agile-ts/core",
"@agile-ts/react": "file:.yalc/@agile-ts/react",
+ "@agile-ts/event": "file:.yalc/@agile-ts/event",
"react": "16.13.1",
"react-native": "0.63.3"
},
diff --git a/examples/react/functional-component-ts/src/App.tsx b/examples/react/functional-component-ts/src/App.tsx
index ceafc704..229611ef 100644
--- a/examples/react/functional-component-ts/src/App.tsx
+++ b/examples/react/functional-component-ts/src/App.tsx
@@ -1,6 +1,7 @@
import React, { useEffect } from 'react';
import './App.css';
-import { useAgile, useEvent, useWatcher } from '@agile-ts/react';
+import { useAgile, useWatcher } from '@agile-ts/react';
+import { useEvent } from '@agile-ts/event';
import {
MY_COLLECTION,
MY_COMPUTED,
diff --git a/package.json b/package.json
index 0751b03a..f7999410 100644
--- a/package.json
+++ b/package.json
@@ -21,6 +21,7 @@
"watch:react": "cd packages/core && yarn run watch",
"watch:multieditor": "cd packages/core && yarn run watch",
"watch:api": "cd packages/core && yarn run watch",
+ "watch:event": "cd packages/event && yarn run watch",
"test": "jest --passWithNoTests",
"test:coverage": "jest --coverage",
"dev:publish": "lerna run build && lerna run dev:publish",
@@ -34,7 +35,8 @@
"pack:core": "cd packages/core && yarn run prepare && yarn run preview",
"pack:react": "cd packages/react && yarn run prepare && yarn run preview",
"pack:multieditor": "cd packages/multieditor && yarn run prepare && yarn run preview",
- "pack:api": "cd packages/api && yarn run prepare && yarn run preview"
+ "pack:api": "cd packages/api && yarn run prepare && yarn run preview",
+ "pack:event": "cd packages/event && yarn run prepare && yarn run preview"
},
"repository": {
"type": "git",
From b25cb992aacc94f87d746fc6004ea6993eeebcea Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Tue, 30 Mar 2021 12:13:39 +0200
Subject: [PATCH 30/35] bumped version
---
.changeset/warm-terms-help.md | 11 +++++++++++
1 file changed, 11 insertions(+)
create mode 100644 .changeset/warm-terms-help.md
diff --git a/.changeset/warm-terms-help.md b/.changeset/warm-terms-help.md
new file mode 100644
index 00000000..29dfedf2
--- /dev/null
+++ b/.changeset/warm-terms-help.md
@@ -0,0 +1,11 @@
+---
+'@agile-ts/api': patch
+'@agile-ts/core': patch
+'cra-template-agile': patch
+'cra-template-agile-typescript': patch
+'@agile-ts/event': patch
+'@agile-ts/multieditor': patch
+'@agile-ts/react': patch
+---
+
+fixed bugs and increased versions
From 01d1a26cbac23624dea72b0e5d1bf32384af657d Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Tue, 30 Mar 2021 12:21:13 +0200
Subject: [PATCH 31/35] fixed readme
---
packages/api/README.md | 20 +++++++----------
.../tests/unit/state/state.persistent.test.ts | 2 +-
packages/event/README.md | 18 ++++++---------
packages/multieditor/README.md | 22 ++++++++-----------
4 files changed, 25 insertions(+), 37 deletions(-)
diff --git a/packages/api/README.md b/packages/api/README.md
index 4ab9c790..c2bb092a 100644
--- a/packages/api/README.md
+++ b/packages/api/README.md
@@ -55,17 +55,13 @@ and [0 external dependencies](https://www.npmjs.com/package/@agile-ts/api).
```
npm install @agile-ts/api
```
-_Be aware that this is no standalone package!_
-To use the Agile Api you have to install the [Agile Core](https://www.npmjs.com/package/@agile-ts/core).
-To find out more take a look into the [docs](https://www.agile-ts.org/docs).
+The `api` package is an extension of AgileTs and doesn't work without the [`core` package](../core/Introduction.md),
+which functions as the brain of AgileTs and is indispensable.
+Unfortunately, we can't combine each `core` with `api` version.
+Therefore, we have created a table which shows which versions fit together without restrictions.
-
-## π Fitting Versions
-| @agile-ts/api | @agile-ts/core | NPM Version |
-| --------------- | ----------------------- | ------------------------ |
-| v0.0.7 | v0.0.1+ | v6+ |
-| v0.0.6 | v0.0.1+ | v6+ |
+| @agile-ts/api | @agile-ts/core | NPM Version | Supported React versions |
+| ----------------------| ----------------------- | ------------------------ | -------------------------|
+| v0.0.7+ | v0.0.7+ | v6+ | 16.8+ |
+| v0.0.6 | v0.0.3 - v0.0.6 | v6+ | 16.8+ |
_Other Versions aren't supported anymore_
-
-## π Documentation
-The Agile Api Docs are located [here](https://agile-ts.org/docs/)
diff --git a/packages/core/tests/unit/state/state.persistent.test.ts b/packages/core/tests/unit/state/state.persistent.test.ts
index 1c3780ad..0bbdb1e7 100644
--- a/packages/core/tests/unit/state/state.persistent.test.ts
+++ b/packages/core/tests/unit/state/state.persistent.test.ts
@@ -26,7 +26,7 @@ describe('StatePersistent Tests', () => {
jest
.spyOn(StatePersistent.prototype, 'instantiatePersistent')
.mockImplementationOnce(function () {
- //@ts-ignore
+ // @ts-ignore
this.ready = false;
});
diff --git a/packages/event/README.md b/packages/event/README.md
index ff03d151..ef195b1b 100644
--- a/packages/event/README.md
+++ b/packages/event/README.md
@@ -24,17 +24,13 @@ MY_EVENT.trigger({name: "jeff"}); // Trigger Event
```
npm install @agile-ts/event
```
-_Be aware that this is no standalone package!_
-To use the Agile Api you have to install the [Agile Core](https://www.npmjs.com/package/@agile-ts/core).
-To find out more take a look into the [docs](https://www.agile-ts.org/docs).
+The `event` package is an extension of AgileTs for React, which doesn't work without the [`core`](../core/Introduction.md)
+and [`react`](../react/Introduction.md) package.
+Unfortunately, we can't combine each `core`, `react` with `event` version.
+Therefore, we have created a table which shows which versions fit together without restrictions.
-
-## π Fitting Versions
-| @agile-ts/api | @agile-ts/core | NPM Version |
-| --------------- | ----------------------- | ------------------------ |
-| v0.0.7 | v0.0.1+ | v6+ |
-| v0.0.6 | v0.0.1+ | v6+ |
+| @agile-ts/event | @agile-ts/core | @agile-ts/event | NPM Version | Supported React versions |
+| ----------------------| ----------------------- | ------------------------ | ------------------------ | -------------------------|
+| v0.0.1+ | v0.0.10+ | v0.0.10+ | v6+ | 16.8+ |
_Other Versions aren't supported anymore_
-## π Documentation
-The Agile Api Docs are located [here](https://agile-ts.org/docs/)
diff --git a/packages/multieditor/README.md b/packages/multieditor/README.md
index f46aaff5..8e7c929d 100644
--- a/packages/multieditor/README.md
+++ b/packages/multieditor/README.md
@@ -76,17 +76,13 @@ and [0 external dependencies](https://www.npmjs.com/package/@agile-ts/multiedito
```
npm install @agile-ts/multieditor
```
-_Be aware that this is no standalone package!_
-To use the Agile MultiEditor you have to install the [Agile Core](https://www.npmjs.com/package/@agile-ts/core).
-To find out more take a look into the [docs](https://www.agile-ts.org/docs).
-
-
-## π Fitting Versions
-| @agile-ts/api | @agile-ts/core | NPM Version |
-| --------------- | ----------------------- | ------------------------ |
-| v0.0.7 | v0.0.7+ | v6+ |
-| v0.0.6 | v0.0.6 | v6+ |
-_Other Versions aren't supported anymore_
+The `multieditor` package is an extension of AgileTs and doesn't work without the [`core` package](../core/Introduction.md),
+which functions as the brain of AgileTs and is indispensable.
+Unfortunately, we can't combine each `core` with `multieditor` version.
+Therefore, we have created a table which shows which versions fit together without restrictions.
-## π Documentation
-The Agile Api Docs are located [here](https://agile-ts.org/docs/)
+| @agile-ts/multieditor | @agile-ts/core | NPM Version | Supported React versions |
+| ----------------------| ----------------------- | ------------------------ | -------------------------|
+| v0.0.7+ | v0.0.7+ | v6+ | 16.8+ |
+| v0.0.6 | v0.0.3 - v0.0.6 | v6+ | 16.8+ |
+_Other Versions aren't supported anymore_
From 61f4ecd242a7f066933a479246a9eeb4f08503d0 Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Tue, 30 Mar 2021 12:51:16 +0200
Subject: [PATCH 32/35] fixed readme
---
packages/api/README.md | 11 ++++++++++-
packages/event/README.md | 5 +++++
packages/multieditor/README.md | 8 ++++++++
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/packages/api/README.md b/packages/api/README.md
index c2bb092a..88b3113d 100644
--- a/packages/api/README.md
+++ b/packages/api/README.md
@@ -12,7 +12,8 @@

-
+
+
## β° Short Example
```ts
// Let't create our API
@@ -36,6 +37,7 @@ console.log(response);
*/
```
+
## β Why Agile Api
#### π
Straightforward
@@ -44,13 +46,16 @@ Write minimalistic, boilerplate free code that captures your intent.
- Automatic transform for JSON data
- Configurable Timeout
+
#### π― Easy to Use
Learn the powerful and simple tools of Agile Api in a short amount of time.
+
#### π Lightweight
Agile Api has an unpacked size of [2kB](https://bundlephobia.com/result?p=@agile-ts/api@0.0.6)
and [0 external dependencies](https://www.npmjs.com/package/@agile-ts/api).
+
## β¬οΈ Installation
```
npm install @agile-ts/api
@@ -65,3 +70,7 @@ Therefore, we have created a table which shows which versions fit together witho
| v0.0.7+ | v0.0.7+ | v6+ | 16.8+ |
| v0.0.6 | v0.0.3 - v0.0.6 | v6+ | 16.8+ |
_Other Versions aren't supported anymore_
+
+
+## π Documentation
+The Agile Api Docs are located [here](https://agile-ts.org/docs/)
\ No newline at end of file
diff --git a/packages/event/README.md b/packages/event/README.md
index ef195b1b..00f50333 100644
--- a/packages/event/README.md
+++ b/packages/event/README.md
@@ -13,6 +13,7 @@
+
## β° Short Example
```ts
const MY_EVENT = App.createEvent();
@@ -20,6 +21,7 @@ MY_EVENT.on((data) => {console.log("hello there " + data.name)}); // Print 'hell
MY_EVENT.trigger({name: "jeff"}); // Trigger Event
```
+
## β¬οΈ Installation
```
npm install @agile-ts/event
@@ -34,3 +36,6 @@ Therefore, we have created a table which shows which versions fit together witho
| v0.0.1+ | v0.0.10+ | v0.0.10+ | v6+ | 16.8+ |
_Other Versions aren't supported anymore_
+
+## π Documentation
+The Agile Event Docs are located [here](https://agile-ts.org/docs/)
\ No newline at end of file
diff --git a/packages/multieditor/README.md b/packages/multieditor/README.md
index 8e7c929d..b70f2b1d 100644
--- a/packages/multieditor/README.md
+++ b/packages/multieditor/README.md
@@ -13,6 +13,7 @@
+
## β° Short Example
```ts
// Let's create our MultiEditor
@@ -65,13 +66,16 @@ Write minimalistic, boilerplate free code that captures your intent.
}
```
+
#### π― Easy to Use
Learn the powerful and simple tools of Agile MultiEditor in a short amount of time.
+
#### π Lightweight
Agile Api has an unpacked size of [14.1kB](https://bundlephobia.com/result?p=@agile-ts/multieditor@0.0.6)
and [0 external dependencies](https://www.npmjs.com/package/@agile-ts/multieditor).
+
## β¬οΈ Installation
```
npm install @agile-ts/multieditor
@@ -86,3 +90,7 @@ Therefore, we have created a table which shows which versions fit together witho
| v0.0.7+ | v0.0.7+ | v6+ | 16.8+ |
| v0.0.6 | v0.0.3 - v0.0.6 | v6+ | 16.8+ |
_Other Versions aren't supported anymore_
+
+
+## π Documentation
+The Agile MultiEditor Docs are located [here](https://agile-ts.org/docs/)
From 39c3b35d0d82945b94a00e4305cdcd023f2b5a85 Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Tue, 30 Mar 2021 13:08:03 +0200
Subject: [PATCH 33/35] fixed readme
---
packages/api/README.md | 2 +-
packages/event/README.md | 4 +--
packages/multieditor/README.md | 3 +-
packages/react/README.md | 59 +++++++++++++++++++++-------------
4 files changed, 41 insertions(+), 27 deletions(-)
diff --git a/packages/api/README.md b/packages/api/README.md
index 88b3113d..7f369377 100644
--- a/packages/api/README.md
+++ b/packages/api/README.md
@@ -60,7 +60,7 @@ and [0 external dependencies](https://www.npmjs.com/package/@agile-ts/api).
```
npm install @agile-ts/api
```
-The `api` package is an extension of AgileTs and doesn't work without the [`core` package](../core/Introduction.md),
+The `api` package is an extension of AgileTs and doesn't work without the [`core`](https://agile-ts.org/docs/core) package,
which functions as the brain of AgileTs and is indispensable.
Unfortunately, we can't combine each `core` with `api` version.
Therefore, we have created a table which shows which versions fit together without restrictions.
diff --git a/packages/event/README.md b/packages/event/README.md
index 00f50333..e11a7cf3 100644
--- a/packages/event/README.md
+++ b/packages/event/README.md
@@ -26,8 +26,8 @@ MY_EVENT.trigger({name: "jeff"}); // Trigger Event
```
npm install @agile-ts/event
```
-The `event` package is an extension of AgileTs for React, which doesn't work without the [`core`](../core/Introduction.md)
-and [`react`](../react/Introduction.md) package.
+The `event` package is an extension of AgileTs for React, which doesn't work without the [`core`](https://agile-ts.org/docs/core)
+and [`react`](https://agile-ts.org/docs/react) package.
Unfortunately, we can't combine each `core`, `react` with `event` version.
Therefore, we have created a table which shows which versions fit together without restrictions.
diff --git a/packages/multieditor/README.md b/packages/multieditor/README.md
index b70f2b1d..87f991fd 100644
--- a/packages/multieditor/README.md
+++ b/packages/multieditor/README.md
@@ -48,6 +48,7 @@ multiEditor.submit();
```
_Do you want to see it in action? Click [here](https://codesandbox.io/s/multieditor-yxt4x)._
+
## β Why Agile MultiEditor
#### π
Straightforward
@@ -80,7 +81,7 @@ and [0 external dependencies](https://www.npmjs.com/package/@agile-ts/multiedito
```
npm install @agile-ts/multieditor
```
-The `multieditor` package is an extension of AgileTs and doesn't work without the [`core` package](../core/Introduction.md),
+The `multieditor` package is an extension of AgileTs and doesn't work without the [`core`](https://agile-ts.org/docs/core) package,
which functions as the brain of AgileTs and is indispensable.
Unfortunately, we can't combine each `core` with `multieditor` version.
Therefore, we have created a table which shows which versions fit together without restrictions.
diff --git a/packages/react/README.md b/packages/react/README.md
index f8af4676..3813f2f4 100644
--- a/packages/react/README.md
+++ b/packages/react/README.md
@@ -1,6 +1,6 @@
-> **Use AgileTs with React and React-Native**
+> **Integrate AgileTs into React or React-Native**
@@ -20,22 +20,40 @@
-Well, the main task of this Integration is to bind States, Collection, .. to React Components.
-This binding ensures that AgileTs rerender the Component, if a bound Instance mutates.
-It also offers some other useful functions that optimize the workflow of AgileTs in React.
+The `react` package is an Integration of AgileTs into React.
+Its main task is to bind States to React Components.
+This binding ensures that AgileTs rerender the Component, whenever a bound State mutates.
+It also offers some other useful functions that optimize the workflow with AgileTs in a React Environment.
-Here is a quick example how such a binding might look like:
+A distinction is made between `Functional` and `Class` Components,
+as we prefer using `React Hooks` in Functional Components.
+But Hooks aren't supported in Class Components, so we came across other solutions,
+to offer the same features there too.
+
+### π Functional Component
+In Function Components we recommend using AgileTs Hooks like `useAgile`,
+which allows us to bind any State to our React Component
```ts
// -- myComponent.jsx ------------------------------------------
-// Binds MY_FIRST_STATE to myComponent.jsx
- const myFirstState = useAgile(MY_FIRST_STATE);
+// Binds MY_FIRST_STATE to myComponent
+const myFirstState = useAgile(MY_FIRST_STATE);
```
+To find out more about `useAgile`, and other Hooks provided by AgileTs,
+checkout the AgileTs Hook [docs](https://agile-ts.org/docs/react/hooks).
-A distinction is made between `Functional` and `Class` Components,
-as we prefer using `React Hooks` in Functional Components.
-But Hooks aren't supported in Class Components, so we came across other solutions,
-to offer the same features there too.
+### π¦ Class Component
+In Class Component we currently only support the `AgileHOC`,
+which helps us binding States to our Component.
+It is a Higher order Component that gets wrapped around our React Component.
+```ts
+// -- myComponent.jsx ------------------------------------------
+
+// Binds MY_FIRST_STATE to myComponent
+export default AgileHOC(myComponent, [MY_FIRST_STATE]);
+```
+To find out more AgileTs in Class Components,
+checkout the AgileHOC [docs](https://agile-ts.org/docs/react/AgileHOC).
@@ -47,12 +65,10 @@ to offer the same features there too.
```
npm install @agile-ts/react
```
-_Be aware that this is no standalone package!_
-
-The React Integration is only an extension of AgileTs and doesn't work without the [Core Package](https://www.npmjs.com/package/@agile-ts/core),
+The `react` package is an extension of AgileTs and doesn't work without the [`core`](https://agile-ts.org/docs/core) package,
which functions as the brain of AgileTs and is indispensable.
-Unfortunately, we can't combine every `core` version with `react` version.
-Therefore, you can find a table that shows which versions fit together below.
+Unfortunately, we can't combine each `core` with `react` version.
+Therefore, we have created a table which shows which versions fit together without restrictions.
| @agile-ts/react | @agile-ts/core | NPM Version | Supported React versions | Supports hook based components |
| --------------- | ----------------------- | ------------------------ | -------------------------|---------------------------------- |
@@ -60,8 +76,6 @@ Therefore, you can find a table that shows which versions fit together below.
| v0.0.6 | v0.0.3 - v0.0.6 | v6+ | 16.8+ | Yes |
_Other Versions aren't supported anymore_
-To find out more checkout our [docs](https://www.agile-ts.org/docs).
-
@@ -69,9 +83,8 @@ To find out more checkout our [docs](https://www.agile-ts.org/docs).
-If you want to find out more about the AgileTs React Integration.
-Checkout our **[docs](https://agile-ts.org/docs/react)**.
-In case you have any questions don't mind joining our [Discord Community](https://discord.gg/FTqeMNCxw7).
+Checkout our **[documentation](https://agile-ts.org/docs/introduction)**, to learn more.
+In case you have any further questions don't mind joining our [Community Discord](https://discord.gg/T9GzreAwPH).
@@ -80,5 +93,5 @@ In case you have any questions don't mind joining our [Discord Community](https:
-Get a part of AgileTs and start contributing. To find out more read the [CONTRIBUTING.md](https://github.com/agile-ts/agile/blob/master/CONTRIBUTING.md).
-
+Get a part of AgileTs and start contributing. We welcome any meaningful contribution π
+To find out more checkout the [CONTRIBUTING.md](https://github.com/agile-ts/agile/blob/master/CONTRIBUTING.md).
From 939a46cce1252d46cbe10d13ad33e2aa06f70d43 Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Tue, 30 Mar 2021 13:30:10 +0200
Subject: [PATCH 34/35] fixed readme
---
README.md | 13 +++++++------
packages/event/README.md | 2 +-
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index fe9a8cbd..e8fbde70 100644
--- a/README.md
+++ b/README.md
@@ -97,14 +97,14 @@ Write minimalistic, boilerplate free code that captures your intent.
```
### π€Έβ Flexible
-- Works in nearly any UI-Framework. Check [here](https://agile-ts.org/docs/frameworks) if your preferred Framework is supported too.
-- Surly behaves with the workflow which suits you best. No need for _reducers_, _actions_, ..
-- Has **no** external dependencies
+- Works in nearly any UI-Layer. Check [here](https://agile-ts.org/docs/frameworks) if your preferred Framework is supported too.
+- Surly behaves with the workflow which suits you best. No need boilerplate code.
+- Has **0** external dependencies
### π― Easy to Use
Learn the powerful tools of AgileTs in a short amount of time.
-A good place to start are our [Quick Starts](https://agile-ts.org/docs/installation)
-or if you are no fan of following any tutorial, checkout your [examples](https://agile-ts.org/docs/examples).
+A good place to start are our [Quick Start Guides](https://agile-ts.org/docs/installation)
+or if you are no fan of following any tutorial, checkout your [Examples](https://agile-ts.org/docs/examples).
@@ -121,7 +121,7 @@ To properly use AgileTs, in a UI-Framework we need to install **two** packages.
```
- and a _fitting Integration_ for our preferd UI-Framework. In my case the [React Integration](https://www.npmjs.com/package/@agile-ts/react).
- Check [here](https://agile-ts.org/docs/installation) if your desired Framework is supported, too.
+ Check [here](https://agile-ts.org/docs/frameworks) if your desired Framework is supported, too.
```
npm install @agile-ts/react
```
@@ -165,6 +165,7 @@ To find out more checkout the [CONTRIBUTING.md](https://github.com/agile-ts/agil
| [@agile-ts/react](/packages/react) | [](https://www.npmjs.com/package/@agile-ts/react) | React Integration |
| [@agile-ts/api](/packages/api) | [](https://www.npmjs.com/package/@agile-ts/api) | Promise based Api |
| [@agile-ts/multieditor](/packages/multieditor) | [](https://www.npmjs.com/package/@agile-ts/multieditor) | Simple Form Manager |
+| [@agile-ts/event](/packages/event) | [](https://www.npmjs.com/package/@agile-ts/event) | Handy class for emitting UI Events |
diff --git a/packages/event/README.md b/packages/event/README.md
index e11a7cf3..d867465a 100644
--- a/packages/event/README.md
+++ b/packages/event/README.md
@@ -1,6 +1,6 @@
# [WIP] Event
-> Handy class for emitting UI updates and passing data with them.
+> Handy class for emitting UI Events
From aee83762423fbddf521e04055e8d4fa4733828ad Mon Sep 17 00:00:00 2001
From: Benno Kohrs
Date: Tue, 30 Mar 2021 13:36:10 +0200
Subject: [PATCH 35/35] fixed readme again
---
packages/api/README.md | 8 ++++----
packages/event/README.md | 9 +++++----
packages/multieditor/README.md | 8 ++++----
packages/react/README.md | 2 +-
4 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/packages/api/README.md b/packages/api/README.md
index 7f369377..b536f961 100644
--- a/packages/api/README.md
+++ b/packages/api/README.md
@@ -65,10 +65,10 @@ which functions as the brain of AgileTs and is indispensable.
Unfortunately, we can't combine each `core` with `api` version.
Therefore, we have created a table which shows which versions fit together without restrictions.
-| @agile-ts/api | @agile-ts/core | NPM Version | Supported React versions |
-| ----------------------| ----------------------- | ------------------------ | -------------------------|
-| v0.0.7+ | v0.0.7+ | v6+ | 16.8+ |
-| v0.0.6 | v0.0.3 - v0.0.6 | v6+ | 16.8+ |
+| @agile-ts/api | @agile-ts/core | NPM Version |
+| ----------------------| ----------------------- | ------------------------ |
+| v0.0.7+ | v0.0.7+ | v6+ |
+| v0.0.6 | v0.0.3 - v0.0.6 | v6+ |
_Other Versions aren't supported anymore_
diff --git a/packages/event/README.md b/packages/event/README.md
index d867465a..2734ba23 100644
--- a/packages/event/README.md
+++ b/packages/event/README.md
@@ -16,7 +16,8 @@
## β° Short Example
```ts
-const MY_EVENT = App.createEvent();
+const App = new Agile();
+const MY_EVENT = new Event(App);
MY_EVENT.on((data) => {console.log("hello there " + data.name)}); // Print 'hello there jeff' if Event gets triggered
MY_EVENT.trigger({name: "jeff"}); // Trigger Event
```
@@ -31,9 +32,9 @@ and [`react`](https://agile-ts.org/docs/react) package.
Unfortunately, we can't combine each `core`, `react` with `event` version.
Therefore, we have created a table which shows which versions fit together without restrictions.
-| @agile-ts/event | @agile-ts/core | @agile-ts/event | NPM Version | Supported React versions |
-| ----------------------| ----------------------- | ------------------------ | ------------------------ | -------------------------|
-| v0.0.1+ | v0.0.10+ | v0.0.10+ | v6+ | 16.8+ |
+| @agile-ts/event | @agile-ts/core | @agile-ts/event | NPM Version | Supported React versions | Supports hook based components |
+| ----------------------| ----------------------- | ------------------------ | ------------------------ | -------------------------|---------------------------------- |
+| v0.0.1+ | v0.0.10+ | v0.0.10+ | v6+ | 16.8+ | Yes |
_Other Versions aren't supported anymore_
diff --git a/packages/multieditor/README.md b/packages/multieditor/README.md
index 87f991fd..ede5cabd 100644
--- a/packages/multieditor/README.md
+++ b/packages/multieditor/README.md
@@ -86,10 +86,10 @@ which functions as the brain of AgileTs and is indispensable.
Unfortunately, we can't combine each `core` with `multieditor` version.
Therefore, we have created a table which shows which versions fit together without restrictions.
-| @agile-ts/multieditor | @agile-ts/core | NPM Version | Supported React versions |
-| ----------------------| ----------------------- | ------------------------ | -------------------------|
-| v0.0.7+ | v0.0.7+ | v6+ | 16.8+ |
-| v0.0.6 | v0.0.3 - v0.0.6 | v6+ | 16.8+ |
+| @agile-ts/multieditor | @agile-ts/core | NPM Version |
+| ----------------------| ----------------------- | ------------------------ |
+| v0.0.7+ | v0.0.7+ | v6+ |
+| v0.0.6 | v0.0.3 - v0.0.6 | v6+ |
_Other Versions aren't supported anymore_
diff --git a/packages/react/README.md b/packages/react/README.md
index 3813f2f4..4f690a8c 100644
--- a/packages/react/README.md
+++ b/packages/react/README.md
@@ -1,6 +1,6 @@
-> **Integrate AgileTs into React or React-Native**
+> Integrate AgileTs into React or React-Native