Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

375
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!