I use ngrx store to maintain application state, normalizr to smooth my data from API calls and Immutable. This works very well so far, but I get a more complex data relationship, and I was wondering how to continue structuring the repository.
To simplify things, I have two sets of objects. Sessions and invoices.
One user logs in and can view his list of sessions. The state in the storage is held in the object ISessions:
export interface ISessions extends Map<String, any> {
result: List<Number>;
entities: {
sessions: Map<Number, ISessions>,
clients: Map<Number, IClient>,
tutors: Map<Number, IProfile>
},
adding: boolean;
loading: boolean;
loadingFailed: boolean;
error: string;
}
(objects contain normalized output - clients and tutors are nested types contained in sessions)
. , , . mannor, .
-, IInvoices:
export interface IInvoices extends Map<String, any> {
result: List<Number>;
entities: {
invoices: Map<Number, IInvoice>,
clients: Map<Number, IClient>,
tutors: Map<Number, IProfile>
},
adding: boolean;
loading: boolean;
}
, :
export interface IAppState {
sessions: ISessions;
invoices: IInvoices;
}
. -. :
- ISessions. , , . , , AppState.sessions AppState.invoices. , IInvoice ( .. Inviosments ISessions, ).
ISessions ISessions -:
:
export interface IAppState {
sessions: ISessions;
invoices: IInvoices;
invoicesSessions: Map<number, ISessions>;
}
- - ISessions. , , . , . , . - ISessions.
, , ISessions IInvoices. , ? , IAppState, .
: , , , "" , , - , , , , - , , ?