Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Feature/compute in sync #222

Merged
merged 12 commits into from
Sep 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
# Following this caching concept https://circleci.com/docs/2.0/persist-data/
# https://circleci.com/docs/language-javascript

version: 2.1

orbs:
node: circleci/node@4.1.0

executors:
node-executor:
docker:
- image: circleci/node:14
node: circleci/node@5.0.2

jobs:

build:
executor: node-executor
executor: node/default # Docker environment in what to execute the steps
steps:
# Checkout Project from Github
- checkout
Expand All @@ -31,9 +27,9 @@ jobs:
# # fallback to using the latest cache if no exact match is found
# - v1-dependencies-

- run:
name: ⏳ Install
command: yarn install
# - run:
# name: ⏳ Install
# command: yarn install

# Not necessary because of auto caching of circleci/node@4.1.0
# - save_cache:
Expand All @@ -55,7 +51,7 @@ jobs:
paths: [ ./* ]

test:
executor: node-executor
executor: node/default
steps:
# https://circleci.com/docs/2.0/configuration-reference/#attach_workspace
- attach_workspace:
Expand All @@ -70,7 +66,7 @@ jobs:
command: yarn run test --runInBand # Tests somehow only get executed with the '--runInBand' Flag

test-coverage:
executor: node-executor
executor: node/default
steps:
# https://circleci.com/docs/2.0/configuration-reference/#attach_workspace
- attach_workspace:
Expand Down
29 changes: 15 additions & 14 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: 🐛 Bug report
about: Create a report to help us improve AgileTs
about: Create a bug report to help us improve AgileTs
title: ''
labels: 'Type: Bug'
assignees: ''
Expand All @@ -11,35 +11,36 @@ assignees: ''

### 🤖 Current Behavior

<!-- Explain your problem (with screenshots, videos, text) in detail -->
<!-- Explain your problem (e.g. with screenshots, text, code snippets) in detail -->

### 🎯 Expected behavior

<!-- A clear and concise description of what you expected to happen. -->

### 📄 Reproducible example

<!-- Create a simple example in Codebox -->
<!-- Create a simple example that reproduces your problem in a code sandbox
(like this one: https://codesandbox.io/s/issue-219-ufcck?file=/src/main.js) -->

### 💡 Suggested solution(s)

<!-- How could we solve this bug? What changes would need to made to AgileTs? -->
<!-- How could we solve this bug? What changes would need to made to AgileTs? Any idea? -->

### ➕ Additional notes

<!-- Add any other context about the problem here. -->
<!-- Add additional context about the problem here. (optional) -->

### 💻 Your environment

<!-- PLEASE FILL THIS OUT -->
<!-- What version/s of AgileTs are you using? -->

| Software | Version(s) |
| ----------------------| ---------- |
| TypeScript |
| npm/Yarn |
| NodeJs |
| @agile-ts/core |
| @agile-ts/react |
| @agile-ts/api |
| @agile-ts/multieditor |
<!-- Any additional important Version Notes? -->
| @agile-ts/core | N/A
| @agile-ts/react | N/A
| @agile-ts/api | N/A
| @agile-ts/multieditor | N/A
| TypeScript | N/A
| npm/Yarn | N/A
| NodeJs | N/A
<!-- Any additional important version notes? -->
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ yarn-debug.log*
yarn-error.log*
.eslintcache
package-lock.json
yarn.lock

# Editor directories and files
.idea
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<img src="https://raw.githubusercontent.com/agile-ts/agile/master/static/header_background.png" alt="AgileTs">
> ⚠️ **No longer actively maintained**.
> In case there will be a higher demand and more known bugs in the future,
> I will be happy to continue improving this project.
> But as for now its stable and can be used in any sort of project.
> In case you face any problem feel free open an [issue](https://github.com/agile-ts/agile/issues).
>
> ❓ If you've any questions feel free to start a [discussions](https://github.com/agile-ts/agile/discussions).

<img src="https://raw.githubusercontent.com/agile-ts/agile/master/static/header_background.png" alt="AgileTs">

> Global State and Logic Library

Expand Down
3 changes: 2 additions & 1 deletion examples/react/develop/fields/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export default function App() {
id: FIELDS.size,
name: `Field #${FIELDS.size + 1}`,
});
}}>
}}
>
Add Field
</button>
</div>
Expand Down
6 changes: 4 additions & 2 deletions examples/react/develop/simple-todo-list/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const App = () => {
method: 'unshift', // to add todo at the beginning of the Collection
});
setCurrentInput('');
}}>
}}
>
Add
</button>
{todos.map((value) => (
Expand All @@ -41,7 +42,8 @@ const App = () => {
onClick={() => {
// Remove Todo at specific primary Key
TODOS.remove(value.id).everywhere();
}}>
}}
>
Remove
</button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"syncDir": "dist",
"scripts": {
"build": "lerna run build",
"prepare": "lerna run prepare",
"changelog": "lerna-changelog",
"bootstrap": "lerna bootstrap",
"watch:core": "cd packages/core && yarn run watch",
Expand All @@ -41,7 +40,8 @@
"pack:react": "cd packages/react && yarn run prepare && yarn run pack",
"pack:multieditor": "cd packages/multieditor && yarn run prepare && yarn run pack",
"pack:api": "cd packages/api && yarn run prepare && yarn run pack",
"pack:event": "cd packages/event && yarn run prepare && yarn run pack"
"pack:event": "cd packages/event && yarn run prepare && yarn run pack",
"install:clean": "shx rm -rf yarn.lock && shx rm -rf node_modules && yarn install && lerna run install:clean"
},
"repository": {
"type": "git",
Expand Down
1 change: 0 additions & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
},
"scripts": {
"build": "shx rm -rf dist && rollup --c rollup.config.js",
"prepare": "yarn run build",
"dev:publish": "yalc publish",
"dev:push": "yalc push",
"watch:push": "tsc-watch --onSuccess \"yarn run dev:push\"",
Expand Down
1 change: 0 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
},
"scripts": {
"build": "shx rm -rf dist && rollup --c rollup.config.js",
"prepare": "yarn run build",
"dev:publish": "yalc publish",
"dev:push": "yalc push",
"watch:push": "tsc-watch --onSuccess \"yarn run dev:push\"",
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/collection/collection.persistent.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from '@agile-ts/utils';
import { logCodeManager } from '../logCodeManager';
import { Collection, CollectionKey, DefaultItem, ItemKey } from './collection';
import { Group, GroupKey } from './group';
import type { Group, GroupKey } from './group';
import {
CreatePersistentConfigInterface,
getSharedStorageManager,
Expand Down Expand Up @@ -137,9 +137,8 @@ export class CollectionPersistent<
// that it was loaded completely.
// After a successful loading assign the now valid Item to the Collection.
else {
const placeholderItem = this.collection().getItemWithReference(
itemKey
);
const placeholderItem =
this.collection().getItemWithReference(itemKey);
placeholderItem?.persist({
key: itemStorageKey,
loadValue: false,
Expand All @@ -148,7 +147,8 @@ export class CollectionPersistent<
followCollectionPersistKeyPattern: false, // Because of the dynamic 'storageItemKey', the key is already formatted above
});
if (placeholderItem?.persistent?.ready) {
const loadedPersistedValueIntoItem = await placeholderItem.persistent.loadPersistedValue();
const loadedPersistedValueIntoItem =
await placeholderItem.persistent.loadPersistedValue();

// If successfully loaded Item value, assign Item to Collection
if (loadedPersistedValueIntoItem) {
Expand Down
26 changes: 12 additions & 14 deletions packages/core/src/collection/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
normalizeArray,
} from '@agile-ts/utils';
import { logCodeManager } from '../logCodeManager';
import { Agile } from '../agile';
import type { Agile } from '../agile';
import { PatchOptionConfigInterface } from '../state';
import { ComputedTracker } from '../computed';
import { ComputedTracker } from '../computed/computed.tracker'; // Not imported directly from '../computed' due circular dependencies
import { Item } from './item';
import { SelectorConfigInterface, Selector, SelectorKey } from './selector';
import {
Expand Down Expand Up @@ -1181,9 +1181,7 @@ export class Collection<DataType extends DefaultItem = DefaultItem> {
* @public
* @param itemKeys - Item/s with identifier/s to be removed.
*/
public remove(
itemKeys: ItemKey | Array<ItemKey>
): {
public remove(itemKeys: ItemKey | Array<ItemKey>): {
fromGroups: (groups: Array<ItemKey> | ItemKey) => Collection<DataType>;
everywhere: (config?: RemoveItemsConfigInterface) => Collection<DataType>;
} {
Expand Down Expand Up @@ -1518,13 +1516,12 @@ export interface CreateCollectionConfigImpl<
initialData?: Array<DataType>;
}

export type CreateCollectionConfig<
DataType extends DefaultItem = DefaultItem
> =
| CreateCollectionConfigImpl<DataType>
| ((
collection: Collection<DataType>
) => CreateCollectionConfigImpl<DataType>);
export type CreateCollectionConfig<DataType extends DefaultItem = DefaultItem> =

| CreateCollectionConfigImpl<DataType>
| ((
collection: Collection<DataType>
) => CreateCollectionConfigImpl<DataType>);

export interface CollectionConfigInterface {
/**
Expand All @@ -1542,8 +1539,9 @@ export interface CollectionConfigInterface {
defaultGroupKey: ItemKey;
}

export interface CollectConfigInterface<DataType = any>
extends AssignDataConfigInterface {
export interface CollectConfigInterface<
DataType extends DefaultItem = DefaultItem
> extends AssignDataConfigInterface {
/**
* In which way the collected data should be added to the Collection.
* - 'push' = at the end
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/collection/group/group.observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Observer,
RuntimeJob,
} from '../../runtime';
import { Group } from './index';
import type { Group } from './index';
import { DefaultItem } from '../collection';
import { logCodeManager } from '../../logCodeManager';

Expand Down
12 changes: 7 additions & 5 deletions packages/core/src/collection/group/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
StateObserver,
StateObserversInterface,
} from '../../state';
import { Collection, DefaultItem, ItemKey } from '../collection';
import type { Collection, DefaultItem, ItemKey } from '../collection';
import { GroupIngestConfigInterface, GroupObserver } from './group.observer';
import { ComputedTracker } from '../../computed';
import { Item } from '../item';
import { ComputedTracker } from '../../computed/computed.tracker'; // Not imported directly from '../computed' due circular dependencies
import type { Item } from '../item';
import { CollectionPersistent } from '../collection.persistent';

export class Group<
Expand Down Expand Up @@ -432,8 +432,10 @@ export class Group<

export type GroupKey = string | number;

export interface GroupObservers<ValueType = any, DataType = any>
extends StateObserversInterface<ValueType> {
export interface GroupObservers<
ValueType = any,
DataType extends DefaultItem = any
> extends StateObserversInterface<ValueType> {
/**
* Observer responsible for the output of the Group.
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/collection/item/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
StateKey,
StateRuntimeJobConfigInterface,
} from '../../state';
import { Collection, DefaultItem } from '../collection';
import { SelectorKey } from '../selector';
import type { Collection, DefaultItem } from '../collection';
import type { SelectorKey } from '../selector';
import { CollectionPersistent } from '../collection.persistent';

export class Item<
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/collection/public/createCollection.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Collection, CreateCollectionConfig, DefaultItem } from '../collection';
import { Agile } from '../../agile';
import type { Agile } from '../../agile';
import { shared } from '../../shared';

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/collection/selector/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from '@agile-ts/utils';
import { EnhancedState, StateRuntimeJobConfigInterface } from '../../state';
import { Item } from '../item';
import { Collection, DefaultItem, ItemKey } from '../collection';
import type { Item } from '../item';
import type { Collection, DefaultItem, ItemKey } from '../collection';

export class Selector<
DataType extends DefaultItem = DefaultItem
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/computed/computed.tracker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Observer } from '../runtime';
import type { Observer } from '../runtime';

export class ComputedTracker {
static isTracking = false;
Expand Down
Loading