I been doing a tutorial and have been caught up in a headache bug for 3 days.
My values aren't being iterated:
<Select value={item.quantity} onChange={(e) =>updateCartHandler(item, e.target.value)}>
{[...Array(item.countInStock).keys()].map((num) => (<MenuItem key={num + 1} value={num + 1}>{num + 1}</MenuItem>))}</Select>
It only outputs : 1.
Should give a list from 1...20
Related
For Ex. I have an arraylike this cids:Array=[{Id:1},{Id:2},{Id:3},{Id:4},{Id:5},{Id:6},{Id:7}---------etc..]
I want output as :
1 2 3 4
5 6 7 8
9
Using *ngFor in angular 4
One way is to convert your arrray[] in array[][4]. And then you will be able to use an imbricated ngFor (ngFor in another ngFor)
Pseudo code :
ngFor* {
ngFor* {
print value;
insert a space;
}
Insert a return line;
}
<span *ngFor="let cid of cids">
{{cid.Id}}
<br *ngIf="(cid.Id)%4==0" />
</span>
How can I use appium to find a element which is not visible in a listview (maybe the element are located in the bottom,and I need to scroll many pages so that i can find the element )
I have used driver.scroll_find_element_by_name() ,but I got a error.
Appium:info: [debug] Didn't get a new command in 60 secs, shutting
down...
My code is as follows:
def scroll_find_element_by_name(self, element_name, time_wait=0.5):
'''
#param:
#rtn: True/False,
#usage:
'''
#
width,height=self.getScreenResolution()
for i in range(maxScrollTimes):
#
try:
self.assertRaises(NoSuchElementException, self.driver.find_element_by_name, element_name)
print "Scroll down " + str(i+1) + ' time to find ' + element_name
except:
print 'SUCCESS: ' + element_name + ' found'
return True
self.driver.swipe(width / 2, 5 * height / 8, width / 2, 3 * height / 8, 1500)#
sleep(time_wait)
print 'UNSUCCESS: ' + element_name + 'NOT found'
return False
For iOS:
el = self.driver.find_element_by_xpath('xpath_value')
self.driver.execute_script('mobile: scroll', {"element": el, "toVisible": True})
Modify 'find_element_by_xpath' to id or whatever you want it to be.
For Android:
I have written my own custom method which looks for the element - if found it will click else move further down. get_element in the below code snippet is one of my own custom method, you should change it to find_elemeny_by_xpath / id etc. Modify it to suit your needs.
def android_is_visible(self, locator):
for _ in xrange(15):
end_y = 950
try:
value = self.get_element(locator).is_displayed()
if value is True:
break
except NoSuchElementException:
self.driver.swipe(470, 1400, 470, end_y, 400)
#self.driver.swipe(start_x, start_y, end_x, end_y, duration=400)
self.driver.implicitly_wait(2)
continue
Also change value of 'end_y = 950' as per your screen size
I'm trying to group my observable values into groups using windowCount, and for each value of each group send request.Then, concatenate those groups so that next group's requests would not start before current group's request are not completed.The problem is some values get skipped.Here's my code.(I'm not making actual ajax calls here, but Observable.timer should work for an example).
Observable.interval(300)
.take(12)
.windowCount(3)
.concatMap(obs => {
return obs.mergeMap(
v => Observable.timer(Math.random() * 1500).mapTo(v)
);
})
.do(v => console.log(v))
.finally(() => console.log('fin'))
.subscribe();
I tried to replace windowCount by creating the groups manually. And it works perfectly. No values are skipped.
Observable.interval(900)
.take(4)
.map(i => Observable.interval(300).take(3).map(j => j + i * 3))
.concatMap(obs => {
return obs.mergeMap(
v => Observable.timer(Math.random() * 1500).mapTo(v)
);
})
.do(v => console.log(v))
.finally(() => console.log('fin'))
.subscribe();
I was under impression that windowCount should group the emitted values the same way.But, apparently it does something else.
I would be really thankful for any explanation of its behavior. Thanks!
The missing values are a result of using a hot observable (Observable.interval(300)) that continues to output values that you are not storing for use.
Following is a slightly simplified version of your code that also logs the times that numbers are emitted. I replaced Math.random() with 1 so that the output is deterministic. I have also loaded the code in jsbin for you to try out:
https://jsbin.com/burocu/edit?js,console
Observable.interval(300)
.do(x => console.log(x + ") hot observable at: " + (x * 300 + 300)))
.take(12)
.windowCount(3)
.do(observe3 => {observe3.toArray()
.subscribe(x => console.log(x + " do window count at: " + (x[2] * 300 + 300)));})
.concatMap(obs => {
return obs.mergeMap(
v => Observable.timer(1 * 1500).mapTo(v)
)
.do(v => console.log(v + " merge map at: " + (v * 300 + 300 + 1500)));
})
.finally(() => console.log('fin windowCount'))
.subscribe();
It results in the output below. Notice that the hot observables march on while the other operators are still being processed.
This is what is giving you the impression that values are being dropped. You can see that windowCount(3) is doing what you thought but not when you thought.
"0) hot observable at: 300"
"1) hot observable at: 600"
"2) hot observable at: 900"
"0,1,2 do window count at: 900"
"3) hot observable at: 1200"
"4) hot observable at: 1500"
"5) hot observable at: 1800"
"3,4,5 do window count at: 1800"
"0 merge map at: 1800"
"6) hot observable at: 2100"
"1 merge map at: 2100"
"7) hot observable at: 2400"
"2 merge map at: 2400"
"8) hot observable at: 2700"
"6,7,8 do window count at: 2700"
"9) hot observable at: 3000"
"10) hot observable at: 3300"
"11) hot observable at: 3600"
"9,10,11 do window count at: 3600"
" do window count at: NaN"
"8 merge map at: 4200"
"fin windowCount"
Edit: further explanation...
After windowCount(3) there is a call to concatMap. concatMap is a combination of map and concatAll.
concatAll:
Joins every Observable emitted by the source (a higher-order
Observable), in a serial fashion. It subscribes to each inner
Observable only after the previous inner Observable has completed (emphasis added), and
merges all of their values into the returned observable.
So, looking at the output above we see that the first windowCount(3) values [0,1,2] are emitted between 1800 and 2400.
Notice that the second windowCount(3) values [3,4,5] are emitted at 1800. concatAll is not ready to subscribe when [3,4,5] is emitted because the previous inner Observable has not completed yet. So these values are effectively dropped.
Next, notice that the previous inner Observable [0,1,2] completes at 2400. concatAll subscribes at 2400.
The next value to appear is the value 8 at 2700 (300ms after the subscription started at 2400). The value 8 is then output by mergeMap at 4200 because of the interval delay of 300 from the subscription start point of 2400 and then a timer delay of 1500 (i.e 2400 + 300 + 1500 = 4200).
After this point the sequence is completed so no further values are emitted.
Please add a comment if more clarification is needed.
I am getting issue in below rule. This is working fine in 5.3 but throwing error (must be boolean expression).
String drl="import com.drools.Applicant;"
+ "rule \"Is of valid age\" "
+ " when $a : Applicant(age > 18 && name matches \"(?i).*\"+ name + \"(.|\n|\r)*\")"
+ " then $a.setValid( true ); "
+ " System.out.println(\"validation: \" + $a.isValid());\n"+
"end";
Issue is with line :
" when $a : Applicant(age > 18 && name matches \"(?i).\"+ name + \"(.|\n|\r)\")"
Any advise.
The expression isn't correct since name cannot be resolved as part of an experssion. Use a binding.
$a : Applicant($n: name, age > 18, name matches \"(?i).*\"+ $name + \"(.|\n|\r)*\")"
(I don't think the the constraint makes much sense - it's merely a test whether a name matches itself, with or without arbitrary characters before and after. Moreover, the ?i is superfluous.)
when i write this line in my jsp page it works fin when i load the page.
<fmt:parseNumber var="leftDays"
value="${( ao.dateOuverturePlis.getTime() - now.getTime() ) / (1000*60*60*24) }"
integerOnly="true" />
but eclipse show me there is a error with red icon
Multiple annotations found at this line:
- Encountered " "(" "( "" at line 1,
column 31.
Was expecting one of:
"." ...
">" ...
"gt" ...
...
- EL Syntax Error
so how can i just get away this red error icon ?
It works finnaly we change it .getTime() by .time like that
<fmt:parseNumber var="leftDays"
value="${( ao.dateOuverturePlis.time - now.time ) / (1000*60*60*24) }"
integerOnly="true" />