Dado que NGRX desaprobó los selectores con accesorios en la versión 11 y el método esperado para usar propiedades es crear selectores de fábrica,
Previo al cambio, con los siguientes dos selectores
export const selector1 = createSelector( state, ( state: FormState, props: {id: string} ) => { // Return items whose parent match the given id return state.items.filter( item => item.parentId === props.id); } ); export const selector2 = createSelector( state ( state, FormState, props: { id: string} ) => { return state.notes.filter( note => note.parentId === props.id); } )podrías llamar a uno de los selectores desde otro, con lo siguiente
export const selector3 = createSelector( state, ( state: FormState, props: {id: string} ) => { // get notes by using an existing selector and passing the state & properties const notes = selector2({ storeName: state}, props) // do some more logic based on the nested call to a selector ... } );ahora que los selectores de fábrica tienen el formato esperado cuando se trata de propiedades, los selectores ahora tienen el siguiente aspecto
export const selector1 = (id: string) => createSelector( state, ( state: FormState ) => { // Return items whose parent match the given id return state.items.filter( item => item.parentId === id); } ); export const selector2 = (id: string) => createSelector( state ( state, FormState ) => { return state.notes.filter( note => note.parentId === id); } )selector2 desde dentro del selector1por ejemplo
export const selector3 = (id: string) => createSelector( state, ( state: FormState ) => { // how is the `state` passed to the nested selector call below? const notes = selector2( id) } );Gracias.
La función createSelector puede recibir otros selectores como argumentos.
Así que podrías hacer:
export const selector3 = (id: string) => createSelector( state, select2(id), (state: FormState, filteredNotes ) => { const notes = filteredNotes; } );