Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

194
Visualizações
Confusion about NgRx Actions in Angular

I've inherited an Angular codebase that contains all the latest tricks and techniques, and I'm having trouble understanding some key things. Normally when I inherit a codebase in any language, I find that I can search it for terms used in one place to see how they are implemented in others and gradually come to an understanding. This doesn't seem to work with NgRx Actions, however. I don't understand the point of code such as

const LOAD = '[Trailer Info Specifics] Load All ';
const load = createAction(LOAD);
export const TrailerInfoActions= {
  load
}

When I search the codebase for "Trailer Info Specifics," it only appears in this one file. So what is the point of the name of the action? What digests this information and acts upon it? I've tried watching videos about Angular Reducers/Actions/Effects/Facades and my eyes just glaze over. None of this makes any sense. I come from the world of imperative programming, so I understand there is a learning curve, but this is just so confusing and none of the tutorials I've found are any good. I'm hoping someone can point me in the right direction.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

The type is the only thing that is required to create and send (store.dispatch) an action. Based on the type, reducers and effects know what to do. They receive all dispatched actions and filter based on this type (that's why it's important to keep action types unique).

It's recommended to follow the "Good Action Hygiene" pattern when declaring types. The template of a type is [Source] Event, this makes it easier to debug/get to know the application because you can see where the action is dispatched.

The reason why you can't find more references of the type is because we don't want magic strings in an application (these are brittle). Instead, you can look for TrailerInfoActions.load to know where the action is dispatched and which reducers/effects do something with it. (The type is a static property on the action creator, which is used to filter actions in reducers/effects.)

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda