Comments (8)
With the action aproach this is not a problem because you will dispatch actions, and you will not have the state as depency.
here I will not help you with anything, use native NGXS
But in general, if you were to use even regular services (rxjs statefull) instead of NGXS, this is a bad approach to have circular dependencies
from entity-state.
@AM4Apps Today, full attention is paid to the new project and plugin:
https://github.com/ngxs-labs/data/blob/master/docs/pages/entity.md
I'm not sure when work on the @ngxs-labs/entity-state
plugin will continue
from entity-state.
I check the data plugin.
I guess it works like a data-service, so you need to subscribe yourself if you want to perform the "Action"(method call). ¿Right?
How it will look a FechAll method in the state like this:
public fetchAll(): Observable<any> {
return this.apiService.fetchAll()
.pipe(
tap((array) => this.setEntitiesAll(array))
);
}
And after you will need to subscribe in the component, ¿Right?
from entity-state.
yes
from entity-state.
There's one more thing, ¿how you deal in the ngxs-labs/data plugin with circular dependencies?
If i am not mistaken you should inject other states to call their methods or to join data from multiple states.
State A => Call State B method(Action)
State B => Call State A method(Action)
or
State A selector get data from State B
State B selector get data from State A
from entity-state.
please create stabcklitz example
from entity-state.
Whould be easier with a more specific model:
export interface IAuthorDTO {
avatar?: string;
bornDate?: Date;
idLocation?: number;
id?: number;
name?: string;
}
export interface ILocationDTO {
authorsIds?: number[];
city?: string;
country?: string;
id?: number;
}
What i am trying is:
- Fetch some of the Authors to AuthorState
- if i don't have in the store the "Location"(idLocation) of an author call LocationState FechById
- After Join Both States in a Selector to represent Author with the associated Locations
And the other way:
- Fetch some of the Locations to LocationState
- if i don't have in the store the "Author"(authorsIds[]) of a location call AuthorState FechById
- After Join Both States in a Selector to represent Locations with the associated Authors
Result
So the dependencies should be like this:
- AuthorState: should have LocationState and ApiAuthorService
- LocationState : should have AuthorState and ApiLocationService
With the action aproach this is not a problem because you will dispatch actions, and you will not have the state as depency.
from entity-state.
Ok thanks, i thought that.
I was checking to work with normalized data with NGXS similar to this Akita Normalized Data
from entity-state.
Related Issues (20)
- Help request / question => how to get an entity by id? HOT 3
- Feature/Discussion: Collection Sort/Filter HOT 3
- Provide beta release? HOT 15
- Behaviour of remove action HOT 5
- Switch to Jest test framework
- EntityState selectors recalculate when any part of root state was updated HOT 7
- Joining Selectors of two EntityState not working
- Make pagination feature optional HOT 2
- Angular 9 upgrade blocked HOT 2
- Allow numbers as keys HOT 2
- Error: Attempted to get members of a non-class: class Add - NGCC HOT 3
- could not get librabry folder in my project HOT 3
- Adding Api Response to Entities HOT 3
- Change UMD Bundling from ES2015 to ES5? HOT 6
- [Feature request] IdStrategy with nested keys
- State of the library HOT 2
- Provide filter operators for actions e.g. ofEntityAction HOT 1
- Migrate to State Operators HOT 2
- Not working developmentMode, getting ERROR TypeError: Cannot add property VALUE_OF_ID, object is not extensible HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from entity-state.