GithubHelp home page GithubHelp logo

salesforce / akita Goto Github PK

View Code? Open in Web Editor NEW
3.7K 67.0 345.0 15.2 MB

πŸš€ State Management Tailored-Made for JS Applications

Home Page: https://salesforce.github.io/akita/

License: Apache License 2.0

TypeScript 96.19% JavaScript 0.42% HTML 3.17% CSS 0.01% Shell 0.01% SCSS 0.20%
angular state-management redux store oop rxjs react vue javascript typescript

akita's People

Contributors

danielnetzer avatar danzrou avatar den-dp avatar dmitryefimenko avatar eilonudi avatar fen89 avatar fernman avatar grandschtroumpf avatar gustav0ar avatar hiepxanh avatar leptoquark1 avatar meghasfdc avatar monsieurman avatar netanelbasal avatar ntziolis avatar ritox842 avatar semantic-release-bot avatar shaharkazaz avatar shairez avatar sjroesink avatar snebjorn avatar svc-scm avatar teamop avatar theorlovsky avatar tony avatar twittwer avatar xaosaki avatar xbaun avatar xealot avatar yackinn 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  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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

akita's Issues

localStorage is not defined in universal app with Akita

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[x] Support request
[ ] Other... Please describe:

Current behavior

i'm using the Akita in app with universal rendering and i got error when i try to start the server.

> dist\server.js:209400 storage: localStorage, ^ ReferenceError: localStorage is not defined at Object.<anonymous> (dist\server.js:209400:14) at __webpack_require__ (dist\server.js:20:30) at Object.@datorama/akita (dist\server.js:132101:18) at __webpack_require__ (dist\server.js:127767:30) at Object../src/app/state/app-state.query.ts (dist\server.js:131374:15) at __webpack_require__ (dist\server.js:127767:30) at Object../src/app/state/index.ts (dist\server.js:131587:10) at __webpack_require__ (dist\server.js:127767:30) at Object../src/app/app.component.ts (dist\server.js:128687:15) at __webpack_require__ (dist\server.js:127767:30)

I don't use localStorage and persistState. I would appreciate some tips on how to make my app work ^^

Environment


Angular version: 6.1.3

[persistState] - local storage replaced by initial state after page refresh

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

I use persistState to persist store state through page refreshs (i.e auth token). After first page refresh, store state gets loaded correctly in memory (store), but local storage is replaced by store initial state. After a second refresh, both memory and local store contains initial state.

Expected behavior

State in local storage remain over multiple pages refreshs

Minimal reproduction of the problem with instructions

Source code here

Environment


Angular version: 5.2.6

Browser:
- [X] Chrome (desktop) version 67.0.3396.99 (64 bits)
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: 8.11.1
- Platform:   Linux Mint 

feature: Multiple indices in EntityStore

edit: I just realized, this isn't the best example, because you could already have the needed index in the tags EntityState. But you get the gist.

Example: you might want to look up items by a tag that's attached to it. Say we have an EntityStore with items where each item can have one or several tags (by id, assume a normalized state).

const items = [
  {id:1, tags: [1, 2]},
  {id:2, tags: [1]}
  {id:3, tags: [2, 3]}
];

The resulting State looks like this:

{
  entities: {
    1: {id:1, tags: [1, 2]},
    2: {id:2, tags: [1]}
    3: {id:3, tags: [2, 3]}
  },
  ids: [1,2,3]
}

Filtering or finding items by tag is cumbersome and slow. It'd be nice to get the possibility of indexing items by one or more keys different from id to get a state similar to this one:

{
  entities: {
    1: {id:1, tags: [1, 2]},
    2: {id:2, tags: [1]}
    3: {id:3, tags: [2, 3]}
  },
  entitiesByTag: {
    1: [1, 2], // just the ids for brevity, actual entities should be here
    2: [1, 3], 
    3: [3]
  },
  ids: [1,2,3]
}

Implementing this reactively isn't feasible as you'd have to either diff or reindex the entire thing on every state change.

(feat): Automatic id creation

I'm submitting a...

[x] Feature request

Current behavior

As of now users have to manage ids on their own.

Expected behavior

Opt in or configurable automatic id creation. (or opt-out and configurable but this would introduce a breaking change)

What is the motivation / use case for changing the behavior?

This would make the framework even more easy to use if you're not using custom IDs.

Todo

  • API design ideas
  • Reopen #35 as it would make sense with automatic id creation.

Add generic for EntityState's error field

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

export interface EntityState<E> {
  ...
  error: any;
}

Expected behavior

export interface EntityState<E, TError = any> {
  ...
  error: TError;
}

What is the motivation / use case for changing the behavior?

correct error typing

Allow update/remove entities by a predicate (not just IDs)

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[X] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

It'd be great if we could update and remove items from the store based on anything else but IDs.
The overloads that would be added would look something like:

update(predicate: ((entity: Readonly<E>) => boolean), newStateFn: ((entity: Readonly<E>) => Partial<E>));
update(predicate: ((entity: Readonly<E>) => boolean), newStateFn: Partial<E>);
update(predicate: ((entity: Readonly<E>) => boolean), newState: Partial<S>);

this would allow to write this:

renameAllNicks() {
  this.update(e => e.name === 'Nick', { name: 'Bob' });
}

I understand that the same result could be achieved with this:

this.update(null, e => e.name === 'Nick' ? { ...e, name: 'Bob' } : e);

...but, that looks more verbose (and this is a very simple example).

Things are a bit worse for the remove case. Instead of proposed suggestion:

this.remove(e => e.name === 'Nick');

...today's solution would have to be the following:

const idsToRemove = [];
for (const id in this.entities) {
  if (this.entities[id].name === 'Nick') {
    idsToRemove.push(id);
  }
}
this.remove(idsToRemove);

I could take a stab at this and submit a PR if you give me a "good to go".

Managing acess rights using Akita

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[x] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

How about a blog post (or a recipe in the documentation, or just a couple of tips) which describes managing access rights, roles, and user groups using Akita? Would be great to see something like that.Thx :)

Just a question (Not an isssue)

Hello Akita Team, where can i found and download the source code for your sample application at http://akita.surge.sh/?

I read also this great post 'The Complete Guide to Authentication in Angular with Akita'
The source code of the post sample application could probably help me since I need to implement first the security using JWT. This is probably already implemented in your sample application at http://akita.surge.sh/.

Thanks!

EntityStore should handle updating of entity ids

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

EntityStore does not handle updating entity's id key correctly

Expected behavior

The following test should pass:

it('should update entity id', () => {
  store.add(new Todo({ id: 1 }));
  store.update(1, { id: 2 });
  expect(store.entities[2].id).toEqual(2);
  expect(store._value().ids).toEqual([2]);
});

Minimal reproduction of the problem with instructions

I have a usecase of optimistic add/update functionality. The code looks like this:
CategoriesService:

addCategory(name: string) {
  const dirtyId = this.categoriesStore.optimisticAdd(name);

  this.api.addCategory(name).subscribe(
    res => this.categoriesStore.updateOptimistic(dirty, res.id),
    err => {
      console.error(err);
      this.categoriesStore.deleteOptimistic(dirty);
    }
  );
}

CategoriesStore:

optimisticAdd(name: string) {
  const category = { id: -1, name, dirty: uuid() };
  this.add(category);
  return category.dirty;
}

updateOptimistic(dirty: string, categoryId: number) {
  this.update(e => e.dirty === dirty, { id: categoryId });
}

deleteOptimistic(dirty: string) {
  this.remove(e => e.dirty === dirty);
}

What is the motivation / use case for changing the behavior?

Akita should support updating entity ids to enable use cases like the one described above.

I already fixed issue locally and can send a PR if you don't have any concerns.

(feat): Infinite scroll plugin

That's what I imagine:

@Component({
  template:  `
    <div class="container">
      <tweet *ngFor="let tweet of infiniteScroll.data$"></tweet>
      <spinner *ngIf="infiniteScroll.loading$"></spinner>
    </div>
  `
})
export class TweetsComponent {
  tweets: InfiniteScrollPlugin<Tweet>;

  constructor(private tweetsQuery: TweetsQuery) { }

  ngOnInit() {
    const request = ({ page }) => this.tweetsService.getTweets(page);

    this.tweets = new InfiniteScrollPlugin(this.tweetsQuery, { container: '.container', offset: 30, request })
   }
}

The plugin responsibilities are:

  1. Listen to the container scroll event and call the API when needed.
  2. Emit the loading state.
  3. Add the new entities to the store.
  4. Expose the data via the data$ key.

Need to do research and check if there is a standard server response for infinite scroll APIs.

The motivation is clear. Almost every application needs an infinite scroll functionality today.

I'd love to hear your opinion and know if anyone wants to take it.

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Missing package.json file.

A package.json file at the root of your project is required to release on npm.

Please follow the npm guideline to create a valid package.json file.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Incompatible with TS 2.9

I'm submitting a...


[x] Bug report  

Current behavior

Compiling with TS 2.9.2 impossible due to type errors:

node_modules/@datorama/akita/src/api/entity-store.d.ts(84,5): error TS2416: Property 'update' in type 'EntityStore<S, E>' is not assignable to the same property in base type 'Store<S>'.
  Type '{ (newState: Partial<S>): any; (id: string | number | (string | number)[], newStateFn: ((entity: ...' is not assignable to type '{ (newState: Partial<S>): any; (id: string | number | (string | number)[], newState: Partial<S>):...'.
    Types of parameters 'newState' and 'id' are incompatible.
      Type 'string | number | (string | number)[]' is not assignable to type 'Partial<S>'.
        Type 'string' is not assignable to type 'Partial<S>'.


node_modules/@datorama/akita/src/api/entity-store.d.ts(85,5): error TS2416: Property 'update' in type 
'EntityStore<S, E>' is not assignable to the same property in base type 'Store<S>'.
  Type '{ (newState: Partial<S>): any; (id: string | number | (string | number)[], newStateFn: ((entity: ...' is not assignable to type '{ (newState: Partial<S>): any; (id: string | number | (string | number)[], newState: Partial<S>):...'.


node_modules/@datorama/akita/src/api/query-entity.d.ts(16,15): error TS2416: Property 'store' in type 'QueryEntity<S, E>' is not assignable to the same property in base type 'Query<S>'.
  Type 'EntityStore<S, E>' is not assignable to type 'Store<S>'.
    Types of property 'update' are incompatible.
      Type '{ (newState: Partial<S>): any; (id: string | number | (string | number)[], newStateFn: ((entity: ...' is not assignable to type '{ (newState: Partial<S>): any; (id: string | number | (string | number)[], newState: Partial<S>):...'.
        Types of parameters 'newState' and 'id' are incompatible.
          Type 'string | number | (string | number)[]' is not assignable to type 'Partial<S>'.
            Type 'string' is not assignable to type 'Partial<S>'.

Expected behavior

Compiling possible ;)

Minimal reproduction of the problem with instructions

Create instances of EntityStore and QueryEntity and try to compile your code with TS 2.9.2 installed

Environment


Angular version: 6.1.0
TS: 2.9.2
 

Why Query and Store?

First, congratulations! Very good. Just one question. Why not unify "Query" and "Store"? I mean make Query methods available on the store (select, etc). It seems strange for me to have 2 services, 1 to change and hold state (Store) and another (Query) to listen for modifications made in the first one (store). Currently these 2 services have to be injected in each place that have operations to change/listen to the state for changes. What is the point I am missing ?

[Feature Request] IOC Container for Stores and @EntityStore Annotation

[X ] Feature request

Current

import { Todo } from './todo.model';
import { EntityState, EntityStore } from '@datorama/akita';

export interface State extends EntityState<Todo> {}

@Injectable({
  providedIn: 'root'
})
export class TodosStore extends EntityStore<State, Todo> {
  constructor() {
    super(initialState);
  }
}

Future

Create Store

import { Todo } from './todo.model';
import { EntityStore } from '@datorama/akita';

@EntityStore(Todo)
export class TodosStore {
    //Custom store methods
    //The store could wrap the service instead of a service wrapping the store
}

Retrieve Store

//Akita IOC Container provides the stores
let todosStore:TodosStore = AkitaContainer.get(TodosStore); 
//If needed initialize state
todosStore.initializeState(intialState);

Initialize State

//If needed initialize state
AkitaContainer.get(TodosStore).initializeState(intialState);

Query

;
let todos$: Observable<Todo[]> = AkitaContainer.get(TodosStore).selectAll();
let todos$: Observable<Todo[]> = AkitaContainer.get(TodosStore).select(filter:Function);
let todo: Observable<Todo> = AkitaContainer.get(TodosStore).select(id:ID);

Thoughts?

PersistState gone

[X] Regression (a behavior that used to work and stopped working in a new release)

persistState no longer present in '@datorama/akita'

akita/cli barrel circular dependency

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report 
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[x] Support request
[ ] Other... Please describe:

Current behavior

Because of the barrel index files, I always get circular dependency warnings at compile time. Example:

  1. movies/state/index.ts imports movies/state/movies.service.ts
  2. The latter imports actors/state/actor.model.ts via barrel actors/state/index.ts
  3. actors/state/index.ts imports actors/state/actors.query.ts
  4. The latter imports movies/state/movies.query.ts via barrel movies/state/index.ts
  5. Three circular dependency warnings 😞

Such cases are unfortunately very common and the barrel files create more unconviniences than they help. Have you encountered such cases and how do you go around with it? Do you just remove the barrel? Thanks!

PS. Are the missing line breaks around providedIn: 'root' in the CLI for Store intentional?
PPS. Is there a slack/gitter room for asking such small questions?

Question: Does transaction combine actions to multiple stores?

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[X] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Question

This issue is just a question / potential request for clarifications in the docs.
The documentation provides examples where the transaction is applied to the methods in the same store. I poked around the code for @transaction, but could not quite understand how it works. The question is whether it can be applied to actions in different stores. For example:

@transaction
actionAffectingTwoStores() {
  this.storeOne.add({ name: 'asd' });
  this.storeTwo.add({ name: 'qwe' });
}

Thanks for the awesome library.

(cli): Consider using schematics ?

Finally got around testing akita for a small project, a 2D map editor for a game. I'll keep you updated. Pretty excited ! πŸ˜ƒ

What do you think about using @angular/schematics for the CLI ?
It's pretty simple and makes sense imo as this framework is coupled to the angular ecosystem.

There's a funny tutorial here.

Seems simple enough I can PR if you want !

Can't use @datorama/akita-ngdevtools in AOT

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ X] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

When running ng serve --aot with @datorama/akita-ngdevtools configured like so...

@NgModule({
    imports: [
        ....
        AkitaNgDevtools.forRoot({ actionsBlacklist: ['@@INIT'] })]
})
export class AppModule {}

I receive the following error

ERROR in Error during template compile of 'AppModule'
  Function calls are not supported in decorators but 'factory' was called in 'AkitaNgDevtools'
    'AkitaNgDevtools' calls 'factory'.

Expected behavior

The dev tools work in AOT.

Minimal reproduction of the problem with instructions

Add the dev tools package and run ng serve --aot.

What is the motivation / use case for changing the behavior?

AOT brings a lot of benefits in validating templates and code while developing features. It would be nice to run the Akita dev tools while building with AOT.

Environment


Angular CLI: 6.1.2
Node: 10.8.0
OS: win32 x64
Angular: 6.1.1
... animations, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
----------------------------------------------------------- @angular-devkit/architect         0.7.2
@angular-devkit/build-angular     0.7.2
@angular-devkit/build-optimizer   0.7.2
@angular-devkit/build-webpack     0.7.2
@angular-devkit/core              0.7.2
@angular-devkit/schematics        0.7.2
@angular/cli                      6.1.2
@ngtools/webpack                  6.1.2
@schematics/angular               0.7.2
@schematics/update                0.7.2
rxjs                              6.2.2
typescript                        2.9.2
webpack                           4.9.2

Browser:
- [ X] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: 10.8.0
- Platform:  Windows

Others:

"strict" compiler option compatibility

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

Errors when compiling with option "strict": true

node_modules/@datorama/akita/src/api/query-config.d.ts(2,35): error TS7006: Parameter 'a' implicitly has an 'any' type. node_modules/@datorama/akita/src/api/query-config.d.ts(2,38): error TS7006: Parameter 'b' implicitly has an 'any' type. node_modules/@datorama/akita/src/enhancers/devtools.d.ts(9,17): error TS7006: Parameter 'state' implicitly has an 'any' type. node_modules/@datorama/akita/src/enhancers/devtools.d.ts(9,24): error TS7006: Parameter 'action' implicitly has an 'any' type. node_modules/@datorama/akita/src/plugins/dirty-check/dirty-check-plugin.d.ts(4,45): error TS7006: Parameter 'head' implicitly has an 'any' type. node_modules/@datorama/akita/src/plugins/dirty-check/dirty-check-plugin.d.ts(4,51): error TS7006: Parameter 'current' implicitly has an 'any' type. node_modules/@datorama/akita/src/plugins/dirty-check/dirty-check-plugin.d.ts(10,22): error TS7006: Parameter 'head' implicitly has an 'any' type. node_modules/@datorama/akita/src/plugins/dirty-check/dirty-check-plugin.d.ts(10,28): error TS7006: Parameter 'current' implicitly has an 'any' type.

And thanks for an awesome library. I really like its simplicity. I've been looking for something similar to this. I've been stuck in the complexity and boilerplate hell of ngrx/redux.

QueryEntity: unexpected selectAll behavior with both filterBy and limitTo options set

I'm submitting a...

could be both, a bug or "working as intended"

Current behavior

Limiting is done before filtering, potentially resulting in an array shorter than limitTo although more items of the source set might have met the filterBy criterion.

Expected behavior

The filtering loop should keep filtering items until the source array is exhausted or the result array has reached a length of limitTo.

Minimal reproduction of the problem with instructions

https://stackblitz.com/edit/angular-gitter-ralyxy

More detailed documentation for UI State

I'm submitting a...


[_] Regression (a behavior that used to work and stopped working in a new release)
[_] Bug report  
[_] Performance issue
[_] Feature request
[X] Documentation issue or request
[_] Support request
[_] Other... Please describe:

Hello. First of all, thank you guys for this amazing product.
Can you please write some examples or complete the documentation section about UI State.
Most interesting thing is how I can read/write UI state?

Docs: memoized / combined selectors

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Performance issue
[x] Feature request
[x] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

No examples in the docs about combining selectors in a memoized way.

Expected behavior

There should be a mention of memoization / combination of selectors. There is a slight hint given in your article on working with normalized data (combineLatest). Yet that still left me with a couple of question marks:

  1. Is combineLatest enough to provide an efficient memoized selector?
  2. Is auditTime absolutely necessary and what kind of trick is auditTime(0)?

If both combineLatest & auditTime are needed in >90% of the cases, I would suggest creating a createSelector() method that wraps everthing up for the user.

What is the motivation?

Minimizing the boilerplate in Query services and the deterrence across the audience with no deep understanding of RxJS.

Update:
After more digging I found the use case for auditTime(0). It's basically a performance boost in case of concurrent updates in the selectors being combined. Basically a substitute for @transaction when the latter is not applicable. The following chart would be helpful in the docs if the team decides for not implementing a createSelector() method:
https://user-images.githubusercontent.com/16118391/43370518-983476a0-9380-11e8-980c-828a8da819d0.png

Documentation issue

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[x] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

On the documentation website, for the version 1.2.0 on the Blog Post section the article with Normalized data does not appear.

https://netbasal.gitbook.io/akita/entity-store/blog-posts

Expected behavior

The article with Normalized data should appear also on the newer version.
This is how it looks like in v1.1.0
https://netbasal.gitbook.io/akita/v/1.1.0/entity-store/blog-posts

Best practice for relations

I'm submitting a...


[x] Question regarding relations

Current behavior

all the documentation currently describes a 1:1 map of models and tables. If you were to have a customer->orders-orderline->[product, user, state] what would be the best practice for Akita ?

Should we have a store per model - how would you then link the relations together ? Is that done in the service - so should the customer service use the order service, or should it create a method to get the orders of the customer

Just a question (Not an issue)

Hello Akita Team I have another question before taking the AKITA path. Our new application will be responsible to configure IOT electronic devices (like NODE-RED) and display lots monitoring values (1000 updates /minutes) coming from these devices. As you stated previously Akita can take this load without any issue. Is our application is a good use case for using AKITA? I mean what AKITA store could bring as advantage over using regular services + RxJx.

Thanks you very much for your time :)

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Missing package.json file.

A package.json file at the root of your project is required to release on npm.

Please follow the npm guideline to create a valid package.json file.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Feature request: Add selectLoading() to non-Entity store/query

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[X] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

Entity queries expose selectLoading() so a component can toggle spinners while an http request is being made.

Queries for non-entities don't have this method and the non-entity stores don't maintain this state.

Expected behavior

Non-entity queries and stores exposing loading state/querying.

What is the motivation / use case for changing the behavior?

When I have sets of entities, entity stores/queries are great. But I often have single items I need to track state for (current session/user, a 'Detail' model of an entity that I'm editing) and I am usually making http requests to get this data from the api.

I would love to be able to query on this loading state for these non-entity collection stores.

I would be willing to help with a PR if you think this feature is worth adding, or if not I'm open to other ways of implementing it.

Thanks.

(feat): PersistState - better ux for exclude / include

I'm submitting a...

[x] Feature request

Current behavior

persistState({
   exclude: [ 'test-store' ]
});

Expected behavior

import { TestStore } from '---/state/test.store';

persistState({
   exclude: [ TestStore ]
});

Motivations

Using imports with class would make for a better development experience => compile time errors.
This is trivial to implement using metadata attached with @StoreConfig().

Note on breaking change

This could either lead to a breaking change if we now only take classes.
Or we could make the include & exclude arrays now take a string or a class as input and check on our end.

I think going for the second option and then going for the class only option in the next major release would be the best.

edit: would like to do a PR but npm hangs on a package because of the proxy at my company...

better error message if forget creating StoreConfig

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[x ] Other... Please describe:

Current behavior

screen shot 2018-08-22 at 11 15 37 am
if @StoreConfig({ name: 'products' }) is missing when you creating store (extends from EntityStore). It will throw this errror, that is not helpful

Expected behavior

  1. it should throw better error like. "did you forget to create StoreConfig({}) ?"
  2. it will be better if we have typescript error check that @storeConfig is must to have when creating Store file.

Minimal reproduction of the problem with instructions

creating store file without @StoreConfig

What is the motivation / use case for changing the behavior?

sometime, new people like me forget to creating it.

Need a possibility to specify the name of state directory

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior


 function buildPath( name, chosenDir ) {
    if(userPath) {
      return `${userConfig}/${chosenDir}/state/${name}`;
    }
     return `${process.cwd()}/${chosenDir}/state/${name}`;
}

Currently the name of state directory is hardcoded in cli source code.

Expected behavior

Please, add a possibility to specify the name of state directory :)

What is the motivation / use case for changing the behavior?

I want a possibility to create state directory with specified name w/o "state" directory inside using cli.
e.g.


/app/states/
    widgets/widgets.store.ts
    ....
    globals/globals.store.ts
    ...
    etc.

Currently i must to do it manually.
Thx =)

Allowing different sorting strategies based on state

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[X] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

Currently, you can configure how to sort your data by providing a sort function either in the @QueryConfig or in select query options.
That's awesome, but what if there is a case when you'd want to provide a custom sorting logic based on state. An API that would allow this would look something like this:

const sortBy: SortBy<CategoriesState, ICategory> =
   (state) => (a, b) => state.sortByOrderNum ? (a.orderNum - b.orderNum) : a.name.localeCompare(b.name);
@QueryConfig({ sortBy })

Unfortunatelly I don't see how such change could be made via a non-breaking change as it's changing the SortBy interface.

What is the motivation / use case for changing the behavior?

Make Akita more flexible

Order enum not exported

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

The docs says that, to user the sortByOrder in the QueryConfig decorator, I must import the Order enum like that:
import { Order } from '@datorama/akita';

But I get this error:
Module '"@datorama/akita/datorama-akita"' has no exported member 'Order'.

Visual Studio suggests importing from this path:
import { Order } from '@datorama/akita/src/internal/sort';

But, again, I get an error:
Module not found: Error: Can't resolve '@datorama/akita/src/internal/sort'

I'm using Akita version 1.3.1.

Expected behavior

import { Order } from '@datorama/akita';

Multiple instances

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[] Feature request
[ ] Documentation issue or request
[x] Support request
[ ] Other... Please describe:

What is the best way to include a store for a component that is going to be reused on different parts in the application and even coexist on the same view? I have a dashboard component that allows the user to create different kind of widgets. A store comes in handy to manage all the different actions and errors. However it kind of feels like I cannot do it with Atika.

Akita ngdevtools error, when redux devtools is not installed

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

Akita ngdevtools shows error if redux devtools does'nt installed in browser.

Expected behavior

I think it would be nice to replace the error with a warning or an information message, because if, for example, I work in a team, but someone from the team does not want to use redux devtools, they get annoying error in the console. :)
Thx so much for the awesome library! :)

Router-state plugin

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

What is the motivation / use case for changing the behavior?

I am considering Akita for a fairly complex app and I seem to miss just a single puzzle piece in migrating from ngrx/ngxs - the router state. This plugin would address two important use cases in my view:

  1. Memoized selectors based on route params and queryParams (e.g. active entity based on id param)
  2. Time travel with Redux DevTools & overall transparency while debugging (Router_Navigate, Router_Cancel, etc.)

Would it fit well in Akita's infrastructure?

EntityStore idKey is not treated accordingly

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

EntityStore does not apply the provided idKey in constructor and thus entities & ids are not treated correctly

Expected behavior

It should accept the idKey given in constructor and treat it accordingly

Minimal reproduction of the problem with instructions

EntityStore constructor:

constructor(private stylesDataService: StylesDataService) {
    super([], {idKey: 'name'});
  }

Checking the idKey of the store:

console.debug(current store state =, this._value(), this.config, idKey=${this.idKey});

Result:
{idKey: "id", storeName: "styles"} {idKey: "id"storeName: "styles" __proto__: Object} idKey=id

Environment


Angular CLI: 6.0.3
Node: 8.9.4
OS: win32 x64
Angular: 6.0.3
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.0
@angular-devkit/build-angular     0.6.0
@angular-devkit/build-optimizer   0.6.0
@angular-devkit/core              0.6.0
@angular-devkit/schematics        0.6.3
@angular/cdk                      6.1.0
@angular/material                 6.1.0
@ngtools/webpack                  6.0.0
@schematics/angular               0.6.3
@schematics/update                0.6.3
rxjs                              6.2.0
typescript                        2.7.2
webpack                           4.6.0



Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Possible Typo into documentation (session.model.ts)

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[x ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Hello Akita Team, when I was looking at the documentation I detected a possible error on the documentation for sessions.model.ts for the createSession function (missing comma & missing timestamp parameter initialization). Double check me because, I'm still learning Akita and WebStorm is complaining and sometime it produce false warning.

export function createSession({
id = null, firstName = '', lastName = '', token = '', timestamp = new Date()
}: Partial) {
return {
id,
firstName,
timestamp,
lastName,
token
};
}

EntityStore - Entities with ID 0

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[x ] Other... Please describe: Question

Current behavior

As I did not find related information in documentation, I'm not sure whether it was designed like this on purpose or not.
EntityStore removes all entities when entity id is 0.
In my case I have entities which are generated in app when the id is a sequence starting from 0.
I have modified it to start from 1 but brought this up only for your attention.

I guess its because of the following where id ? returns false

remove(id?: ID | ID[], resetActive?) {
    if (!toBoolean(id)) this.setPristine();

    const ids = id ? coerceArray(id) : null;
    this.setState(state => _crud._remove(state, ids, resetActive));
  }

Version 1.1.0

Cancel uncompleted actions on repeat

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[x] Feature request
[x] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

Running three actions of the same type in a row will always result in three updates of the store.

Expected behavior

The ability to set an option that would cancel the execution of the previous action stream (switchMap behavior).

Maybe something like:
{ type: '[Todos] Fetch All', cancelUncompleted: true }

What is the motivation / use case for changing the behavior?

Clicking three times on the fetch button should normally not end up in three updates of the store.

I am not sure Akita can support this out of the box, but at least a documentation recipe of how can this be achieved with RxJS would be helpful.

Data retrieve from the API endpoint is always named with the last entry of the MongoDB collection

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

I am sending a GET http request to an API endpoint to retrieve data from a MongoDB database with mongoose (MEAN stack).
The data received is always named with the name of the last entry of the collection.

Expected behavior

The data should have the same name as the database data.

Minimal reproduction of the problem with instructions

Compare the data display on the stackblitz and the API endpoint :
stackblitz : https://stackblitz.com/edit/angular-2qqqx4
API endpoint : https://dev-api.proforeigner.com/api/nationalities

What is the motivation / use case for changing the behavior?

I am not retrieving good data to display.

Environment


Angular version: 6.1.6


Browser:
- [x] Chrome (desktop) version 68.0.3440.106
 
For Tooling issues:
- Node version: v8.11.3
- Platform:  Mac

Others:

MEAN stack with 
- MongoDB v3.6.7
- Express v4.16.3

Persist only slices of a store

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

When I want to persist a part of the state I only can include/exclude based on complete stores.

Expected behavior

It would be nice to select a nested slice of a store, e.g. 'auth.tokens'.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

I want to persist only some parts of a store, e.g. the tokens in the auth store and reset dynamic properties like loading in an EntityStore.
(like it's possible in the ngxs plugin)

EntityStateHistoryPlugin undo allows only 1 ID

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

undo and redo accept only 1 ID

Expected behavior

Should accept multilple IDs

What is the motivation / use case for changing the behavior?

According to documentation, EntityStateHistoryPlugin undo/redo should accept multiple IDs.

Environment

Akita 1.2.0

Custom action not displayed in Redux DevTools

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report 
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

Skills - @Transaction gets displayed instead of the defined custom action in Redux DevTools. Neither @action nor applyAction does work.

Expected behavior

Redux DevTools should display [Skills Service] Fetch All.

Minimal reproduction

https://stackblitz.com/edit/akita-todos-app-uiqjdx?file=src%2Fapp%2Fskills%2Fskills-data.service.ts

Am I doing it wrong by defining the custom action in the main service? It's the only place it makes sense for me. Thanks for your support!

Persiststate and Pristine

[x ] Support request

When using persist state should the store not be set to pristine false, as its restored data from (in this case) local storage.

Question: Integration with Apollo GraphQL.

Hi, first congratulations for quick and new realease, I'm really hyped about it.
Going straight to the point, have you ever used and implemented a graphql endpoint with Apollo? The "problems" starts when using a state manager, such as NgRx, which case the apollo-angular developer is currently working on a solution to "merge" the two generated stores (NgRx and apollo). Yes, Apollo create it own inMemoryCache, creating a separate store.
Do you know a way of doing this? It's necessary? (since I do not know the internal things of Akita); If you're interested, should I make a request from this?
Thanks!

(feat): Helper function: addAndSetActive()

I'm submitting a...

[x] Feature request

Expected behavior

A function for EntityStore:

addAndSetActive(entity: E)

What is the motivation / use case for changing the behavior?

I think it is a pretty common use case to create an entity and set it as active right after.

In my case I'm creating an area in my map and the user then edits it.

(bug): Active stays hydrated after calling store.set()

I'm submitting a...

[x] Bug report 

Current behavior

After calling store.set(), active stays hydrated.

Expected behavior

Maybe calling store.set() should reset active to null and then set entities for more robustness ?

What is the motivation / use case for changing the behavior?

By example, if we call store.set([]), the id active is pointing to won't exist anymore and could cause many bug.

Just a question (Not an issue)

Hello Is akita suitable for fast realtime monitoring of massive data update on the screen? Let say we receiving 1000 realtime values update per minutes and need to display changes on the web page using angular 5, can akita keep up with this situation.

Thanks for your time!

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.