I have two observables that both resolve to a simple string. I am looking for a non-deprecated way to take the results of 2 observables, create an object, and pass the object into another method that returns an observable.
Lets say I have the following:
// both are Observable<string> name$ age$ // I want this let body = { name: (string result of name$), age: (string result of age$) } this.httpClient.post<any>("some endpoint", { body: body });
Question:
Do I have to subscribe to the string observables before creating the object? Or would this not be best practice? The docs recommend using zip but vscode is telling me that it is deprecated.
https://stackoverflow.com/questions/66609109/how-to-combine-the-results-of-2-observables-as-properties-on-an-object March 13, 2021 at 08:59AM
没有评论:
发表评论