Giter VIP home page Giter VIP logo

agile-ts / agile Goto Github PK

View Code? Open in Web Editor NEW
95.0 95.0 8.0 9.61 MB

🌌 Global State and Logic Library for JavaScript/Typescript applications

Home Page: https://agile-ts.org

License: MIT License

TypeScript 96.98% JavaScript 2.17% HTML 0.35% CSS 0.51%
agiel-ts agile api functional-reactive-programming global-state javascript modular react-global-state react-native react-state-management reactive reactjs redux-alternative replace-redux simple spacy state state-management typescript vue

agile's People

Contributors

bennobuilder avatar dependabot[bot] avatar github-actions[bot] avatar leopf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

agile's Issues

Merge loaded Group value from Storage into existing Group Value?

🐛 (Bug report) Think report

🤖 Current Behavior

If we persist a Group, and than manually add a new ItemKey to it (in code), it overwrites this manually added ItemKey because it ovewrites it with the Storage value.

🎯 Expected behavior

Not sure yet
It should merge the loaded value into the existing value, so that no ItemKey, that gets added after the first permantent save, gets missing.

📄 Reproducible example

Checkout the Examples of AgileTs

➕ Additional Notes

grafik
Job when Group value gets loaded from local storage

Initial Value that got added after the Group got persisted for the first time.
grafik

Create api package tests

To be 90% sure that everything works in the @agile-ts/react package we should create jest tests for it.
Because as seen yesterday it doesn't work properly yet ^^

onLoaded (State)

Create function that gets triggerd if the Storage Value of a State got loaded.

Trigger specific Events

Add Feature to Trigger a specific Callback in Event

For Instance:

MY_EVENT.on('error', (payload) => {console.log("Triggered Error")});
MY_EVENT.on('warning', (payload) => {console.log("Triggered Warning")});
MY_EVENT.on('success!', (payload) => {console.log("Triggered Success")});

MY_EVENT.trigger("success", {message: "blba"}); // success!

Add initialData to Collection Config

🆕 Feature Request

❓ Is your feature request related to a problem?

No

📄 Describe the solution you'd like

If you create a Collection you maybe want to directly add some intital Data

App.Collection({ initialData: [{id: 1, name: "frank"}] })

Add ComputedTracker to each function that returns something

🐛 Bug report

🤖 Current Behavior

Currently functions like exists(), is(), .. can't get autodetected by the Computed Class since we don't track it.

🎯 Expected behavior

Track each class that doesn't return this, since it can influence the Computed Value

📄 Reproducible example

grafik

💡 Suggested solution(s)

add ComputedTracker.tracked(this.observer);
grafik

Rewrite Agile Core Tests

Because the Tests of this Framework are bad and depend on each other!
They work and are doing her job but they are not well written.

Subscribe to Group value

🆕 Feature Request

❓ Is your feature request related to a problem?

no

📄 Describe the solution you'd like

Allow the subscription to just the Group value and not the Group output.

// MyCompoent.tsx
const value = useValue(MY_GROUP);
console.log(value); // Returns [1, 2, 3, 4]

const output = useOutput(MY_GROUP);
console.log(output); // Returns [{id: 1, name: 'jeff', ..}]

📃 Describe alternatives you've considered

no

Think about extracting `utils` and the `logger` from the core package

🆕 Feature Request

Extract some utils and the Logger Class into separate packages.
Because we might use the Logger Class as well in other packages and not only in the core.
The same counts for the utils.
So maybe extract these into two separate packages called:

  • @agile-ts/logger
  • @agile-ts/utils

Add '.move()' function to Collection

This allows us to move a Item from one Group to another Group

MY_COLLECTION.move(1, 'group1', 'group2');

This moves the Item with the primaryKey 1 from group1 to group2

Collection typeError if passing it into useAgile

🐛 Bug report

🤖 Current Behavior

If you pass a Collection, thats value is not from type DefaultItem into useAgile it complains, that
Collection<DefaultItem> is not Collection<YourCustomInterface>

grafik

Issue is:

TS2769: No overload matches this call.   Overload 1 of 2, '(deps: [] | (Observer<any> | State<any> | Collection<DefaultItem> | undefined)[], key?: string | number | undefined, agileInstance?: Agile | undefined): never[]', gave the following error.     Argument of type 'Collection<collectionValueInterface>' is not assignable to parameter of type '[] | (Observer<any> | State<any> | Collection<DefaultItem> | undefined)[]'.       Type 'Collection<collectionValueInterface>' is missing the following properties from type '(Observer<any> | State<any> | Collection<DefaultItem> | undefined)[]': length, pop, push, concat, and 28 more.   Overload 2 of 2, '(dep: Observer<any> | State<any> | Collection<DefaultItem> | undefined, key?: string | number | undefined, agileInstance?: Agile | undefined): any', gave the following error.     Argument of type 'Collection<collectionValueInterface>' is not assignable to parameter of type 'Observer<any> | State<any> | Collection<DefaultItem> | undefined'.       Type 'Collection<collectionValueInterface>' is not assignable to type 'Collection<DefaultItem>'.         Types of property 'data' are incompatible.           Type '{ [key: string]: Item<collectionValueInterface>; }' is not assignable to type '{ [key: string]: Item<DefaultItem>; }'.             Index signatures are incompatible.               Type 'Item<collectionValueInterface>' is not assignable to type 'Item<DefaultItem>'.                 The types of 'observer.state().computeMethod' are incompatible between these types.                   Type 'ComputeMethod<collectionValueInterface> | undefined' is not assignable to type 'ComputeMethod<DefaultItem> | undefined'.                     Type 'ComputeMethod<collectionValueInterface>' is not assignable to type 'ComputeMethod<DefaultItem>'.                       Types of parameters 'value' and 'value' are incompatible.                         Type 'DefaultItem' is not assignable to type 'collectionValueInterface'.

🎯 Expected behavior

It should be possible to pass a Collection into useAgile without any typeerror

📄 Reproducible example

See example

Add weight to sideEffects

🐛 Bug report

🤖 Current Behavior

It can happen, that the 'rebuildStorageSideEffect' gets called before the the 'rebuildGroupSideEffect' than it stores the
not rebuild value..

grafik

Currently we are lucky, that the 'rebuildGroupSideEffects' got added before the 'rebuildStorageSideEffect'..
but that might not be always this way

📄 Reproducible example

See examples

💡 Suggested solution(s)

Add a weight to the sideEffect, to see in which order it should get exectued!!

Multiple Agile Storages

Maybe you don't want to save everything in one storage.. like the LocalStorage since it has a limited capacity..

Prints warning when loading persisted Collection

🐛 Bug report

🤖 Current Behavior

If you store a Collection in an external Storage with some Items that were not initially added,
the Collection tries to rebuild the Group on each loaded Item when loading the Collection.
And since not every Item was loaded yet, a warning is printed that the Item doesn't exist in the Collection.

🎯 Expected behavior

Shouldn't print warning and rebuild the whole Group when one Item was loaded

Related to issue:
#113

📄 Reproducible example

https://codesandbox.io/s/agilets-first-collection-uyi9g

When adding multiple Items to the TODO-List
and then refreshing the application.
You see the warning be printed, when the persisted value is loaded into the Collection.

💡 Suggested solution(s)

Fix Group rebuilds #113

Reduce and optimize Group rebuilds

🆕 Feature Request

❓ Is your feature request related to a problem?

If you have a very very big Group and you mutate its value.. it rebuilds the whole Group output on a single change which might result in performance leaks.

📄 Describe the solution you'd like

Rebuild the Group only if the built output is needed.. for instance when calling output, or items

📃 Describe alternatives you've considered

bad performance

Switch 100% to yarn

currently some packages are using yarn.lock some package.lock and some both

Outsource Log Messages

🆕 Feature Request

❓ Is your feature request related to a problem?

No

📄 Describe the solution you'd like

Outsource all log messages from the actual code.

pros:

  • better maintainability
  • better testability
  • single line which redirects to log messages instead of a up to 10lines long log message

cons:

  • larger bundle size (2kb)
  • work to outsource the log messages and update tests

📃 Describe alternatives you've considered

Don't outsource all log messages from the actual code.

Create react package tests

To be 90% sure that everything works in the @agile-ts/react package we should create jest tests for it.

Modify Item trough Selector

It would be pretty cool if we could modify the selected Item of the Selector through the Selector.

MY_COLLECTION.collect({id: 1, name: 'hans'})
const MY_SELECTOR = MY_COLLECTION.createSelector("mySelector", 1);
MY_SELECTOR.patch({name: 'frank'});
MY_COLLECTION.getItemValue(1); // Returns' {id: 1, name: 'hans'}' but it would be cool if the value is now '{id: 1, name: 'frank'}'

Create basic Vue Integration

🆕 Feature Request

❓ Is your feature request related to a problem?

No

📄 Describe the solution you'd like

A Vue Integration that allows a user to use AgileTs in a Vue 2.0 Project

📃 Describe alternatives you've considered

No

Optimise method and interface descriptions for the `core` package

🆕 Feature Request

Something like that

/**
 *  tagline.
 *
 *  more description.
 *
 *  Learn more: [link to documentation part]
 * 
 * @param {object} x - description.
 * @param {State} y - description.
 * @returns {State} - description.
 *
 */
function myCoolMethod() {
  // xyz
}

Select 'null' via Selector

🆕 Feature Request

❓ Is your feature request related to a problem?

No

📄 Describe the solution you'd like

Sometimes you don't know the to select Item yet,
but you need the Selector instance..

const MY_SELECTOR = USERS.createSelector('user', null);

📃 Describe alternatives you've considered

no

Create proper Logger

Currently if you allow logging.. many things get logged..
maybe some configs for the logger might be useful.. like logCore, logEditor, logWhatever..

ReadMe of the core package doesn't get detected by npms-analyzer

🐛 Bug report

🤖 Current Behavior

npms-analyzer doesn't detect readme in core package since it analyzes the GitHub repository and not the actual npm build.
-> 0 point for the readme -> smaller search score

npms-io/npms-analyzer#258

🎯 Expected behavior

npms-analyzer detects the readme and gives us 0.6 points ;D

💡 Suggested solution(s)

Create a fake readme with lorem ipsum,
in order to get the points.. since the readme will be added during the build process.

Fix `0` as itemKey issue

🐛 Bug report

🤖 Current Behavior

If you have a Collection and have an Item with the itemKey 0..
it will have problems with this itemKey because we often do

if(!itemKey)
// ..

instead of

if(itemKey == null)
// ..

🎯 Expected behavior

Shouldn't be a problem having an itemKey called 0

💻 Your environment

Software Version(s)
@agile-ts/core 0.0.15

Async Compute method in Computed Class

🆕 Feature Request

❓ Is your feature request related to a problem?

No

📄 Describe the solution you'd like

Make the Computed Class accept an async compute method.

const MY_COMPUTED = App.createComputed(() => {
  await xyz;
});

📃 Describe alternatives you've considered

no

Endless remove loop when trying to remove from Selector selected Item

🐛 Bug report

🤖 Current Behavior

When we remove an Item that is currently selected by a Selector,
the remove method calls 'reselect' on the affected Selectors
to hold a reference to the now defunct Item. (-> Selector creates placeholder Item)

// ..

  // Remove Item from Collection
      delete this.data[itemKey];

      // Reselect Item in Selectors (to create new dummyItem that holds reference)
      for (const selectorKey in this.selectors) {
        const selector = this.getSelector(selectorKey, { notExisting: true });
        if (selector?.hasSelected(itemKey)) selector?.reselect({ force: true });
      }

// ..

And when we now try to remove the placeholder Item,
it won't work because the Selector needs to hold a reference to it.
This is an expected behavior, but it shouldn't cause a rerender on each 'placeholder' Item remove try.

🎯 Expected behavior

Doesn't remove required placeholder Item and create it again with a rerender as side effect.

Create proper structor for examples

like this

examples:
  --- react
  ------ typescript
  ----------- class-component-example
  ----------- functional-component-example
  ----------- multieditor-example
  ------ javascript
  ----------- TODO
  --- angular
  ------ TODO

useAgile returns never if you pass (State/undefined) property in Array syntax

You can test it with the code below.
There 'undefinedOrState' is typeof never but it should be the type (State | undefined)

// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-1.html

type AgileHookArrayType<T> = {
  [K in keyof T]: T[K] extends State<infer U>
    ? U[]
    : T[K] extends undefined
    ? undefined
    : never;
};

class State<ValueType = any>{
    public value: ValueType;

    constructor(initialValue: ValueType){
      this.value = initialValue;
    }
}

// --- Testing of keyof ----------

interface Person {
  name: string;
  age: number;
  location: string;
}
type x = keyof "test";
type y = keyof State;
type v = keyof Person;

// -------------------------------

export function useAgile<X extends Array<State | undefined>>(
  deps: X | []
): AgileHookArrayType<X> {
return "" as any;
}

const state = new State<string>("text");
const undefinedOrState: State | undefined = Math.random() > 1 ? new State<number>(3) : undefined; 
const [test, test2, test3] = useAgile([state, undefined, undefinedOrState]);

fix react-typescript template

to work properly it needs these missing dependencies..

"dependencies": {
"typescript": "^4.2.3",
},

"devDependencies": {
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.3"
},

In addition we have to think about how to increase the dependency agile-ts version after each release

Update JobConfig

Instead of having the property forceRerender..
it should have the property called 'force'

force = Create Job no matter what happens and not create Job and rerender no matter what happens
If it should rerender will be defined in the background property
-> if force & !background -> rerender and create job no matter what happens
-> if force & background -> don't rerender but create job

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.