简体   繁体   中英

lint error related to return in subscription with more than one action

Hello developers I´m subscribing to a service, and on its next() if everytinh is fine, i do expect to do several things, but I´m receiving this lint error:

Unexpected use of comma operator     

the subscription would be kind of:

  someMethod(){
     someService.MySergvice().subscribe(
        ()=>{ return (action1,action2,action3)},
       .....
     )
  }

then i receive this error: Unexpected use of comma operator By the way i did try with this structure:

 someService.MySergvice().subscribe(
        ()=> (action1,action2,action3),
       .....
     )  )
  }

And kept the same How can i improve this situation?

The comma operator isn't commonly used like this. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator for more details. In this situation, it's completely useless and doesn't make sense.

This is stuff you should be looking for in documentation first.

This may not be doing what you think. It's always returning action3 . If you wanted to return an array, use square brackets instead.

 someService.MySergvice().subscribe(
        ()=> [action1, action2, action3],
       .....
     )  )
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM