toddmotto / ama

Ask me anything!
20 stars 3 forks source link

How to set the State Interface with http request #77

Open m4rkss opened 6 years ago

m4rkss commented 6 years ago

Hi,

I try to make some changes using this post:https://toddmotto.com/component-architecture-reactive-forms-angular But I try to initialize the State interface with HttpRequest values: How can I get this values from request?

I try in Pizza.service.ts:

 state: State = {
         sections: this.getSecciones_Get()
    };
  private subject = new BehaviorSubject<State>(this.state);
    store = this.subject.asObservable().distinctUntilChanged();

      select<T>(name: string): Observable<T []> {   
        return this.store.pluck(name);
    }

My interface AppMain.ts:

export interface AppMain{
    name: string,
    sections: ISections []

}
export type Sections= ISections;

export interface ISections{

      SectionName:string;
     NumberSection:number;
}

Please can you help to adapt this solution initialize alues from http request?

Many thanks.