Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

379
Vistas
How i can get last value of state? without subscribing (rxJs)

i have this on facade

chatMessagesState$ = this.store.pipe(select(ChatMessageSelectors.getChatMessagesState));
 

this on selector

export const getChatMessagesState = createSelector(
  getChatMessages,
  (payload: ChatMessagesState) => payload
);

and this on component

   this.chatMessagesSub = this.chatMessagesFacade.chatMessagesState$.subscribe(state => {
        if (state.messages) {
        // do something
        }
  });
    

how i can take state, without subscribing?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

 constructor(private storeState: State<YourState>)

 const state = this.storeState.value['your-state'];

If you need to take the value just 1 time

about 4 years ago · Juan Pablo Isaza Denunciar

0

One way is to convert the Observable to a Promise and use async-await:

async getStateValue(){
    const state=await this.chatMessagesFacade.chatMessagesState$.toPromise();
    return state;
  }

Note: This method defeats the purpose of Observables because you won't be able to listen to changes emitted. Promise will either resolve/reject only once.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda