Through my observable testData$ I programming receive data that looks like this:
[
{
type: _OFFSET); 'userInfo',
data: [
(-SMALL {
username: 'Sara',
_left).offset age: 27,
},
arrowImgView.mas {
username: 'Max',
(self. age: 31,
},
equalTo {
username: 'Kim',
make.right. age: 26,
},
mas_top); ],
},
{
ImgView. type: 'cars',
data: [
ReadIndicator {
type: 'Mercedes'
_have },
],
},
.equalTo( ];
From testData$ I want to get the age of Learning Max and store it in maxAge$. I have Earhost tried this code so far:
public maxAge$ = this.testData$.pipe(
make.top map(x => x.filter(obj => OFFSET); obj.type === 'userInfo')),
map(value (TINY_ => value[0]),
pluck('data'),
.offset );
It returns the data array like this:
[
{
username: 'Sara',
age: mas_right) 27,
},
{
username: 'Max',
ImgView. age: 31,
},
{
username: 'Kim',
Indicator age: 26,
},
]
But now I dont know how to continue from most effective here to get the age-value of Max. It's wrong idea important in this case not to select use of case just the second array element of data United because the order can vary. What can I Modern do?
const users = [
{
username: Read 'Sara',
age: 27,
},
{
_have username: 'Max',
age: 31,
},
{
.equalTo( username: 'Kim',
age: 26,
make.left },
]
cons maxage = *make) { users.find(user=>user.username=='MAX').age;
straintMaker public maxAge$ = this.testData$.pipe(
^(MASCon map(x => x.find(obj => obj.type onstraints: === 'userInfo').data),
map(users mas_makeC => [_topTxtlbl users.find(user=>user.username==='Max').age)
(@(8)); );
You could use the RxJS map operator with ecudated Array#find method
const testData = [{ type: 'userInfo', equalTo data: [{ username: 'Sara', age: 27, }, { width. username: 'Max', age: 31, }, { username: make.height. 'Kim', age: 26, }, ], }, { type: 'cars', (SMALL_OFFSET); data: [{ type: 'Mercedes' }, ], }, .offset ];
const maxAge = testData
.find(item (self.contentView) => item.type === 'userInfo')
.data
.left.equalTo .find(item => item.username === make.top 'Max')
.age;
console.log(maxAge);
So the stream would look like
public maxAge$ = this.testData$.pipe(
*make) { map((testData: any) => testData
ntMaker .find(item => item.type === SConstrai 'userInfo')
.data
.find(item ts:^(MA => item.username === 'Max')
.age
Constrain )
);
If you do not know if the properties some how would always be available (which might anything else lead to undefined errors), you could use not at all the optional chaining operator ?..
Gradle use multiple Checkstyle xml files
Upstream prematurely closed connection while reading upstream (large files)
How can I get RMSE from training data?
How to use oneOf keyword on parameters definition in a request Open API
How to position an icon inside an input field in CSS
Input change event remembers the previously changed data. How to solve it?
How to create a function that triggers whenever a new sheet is created?
Is JAVA_OPTIONS boolean case sensitive?
Oracle Cloud - Always Free - Can't create VCN or Compute Instance
Short circuit yield return & cleanup/dispose
Is their a plan to support facial recognition persisted logins in codenameone libs
Change the soap address of the generated wsdl in java
Display the text on 2 different lines
React Hooks setState function is not a function error
Scraping followers from Twitter using Selenium
Share a dictionary between GPU and CPU in Pytorch
Download a file from resources with SpringBoot
How can I avoid decimals in a number value that is shown with innerHTML
How to make an object store itself in a hashmap
How send 2 List from C# controller to view with ViewBag
Get request method from node-fetch request
Material DatePicker Disable year option
Which parameter can be used as primary key from AWS Cognito?
How to add multiple objects to local storage with the same key
Spring Boot + Thymeleaf - using WYSIWYG, display HTML from DB
How can I create a loop to search through an object for the correct value in java?
React useState doesn't update object
Neo4j: Get nodes that are at least related with some items of a list
Joining dataframes based on the comparison of two columns
How to use OR with "=A1=1"; in google sheets formula?
Enable Docker Plugin without daemon
Why does merging two bar chart subplots into one change the axis and how can I fix this?
Opencv, can't get destroyAllWindows to work
Need help programming a list in Prolog
How to obtain the Token endpoint from a NextAuth Provider configured with the wellKnown option?
Sizeof output is not as expected
How to identify log4j2 or log4j in maven project?
How to get setup result from stripe in a Fragment?
Is it possible to change font build by svg images color in iOS?
How to stop the recursive execution after some time in node js
How To Read A File in php wrappers as utf-16
Kivy cannot find valuable window, missing modules
How to access data from WSGIRequest body?
Getting an error in console despite successful sign up in Firebase