Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 29 2016 21:28
  • Dec 29 2016 21:28
  • Dec 29 2016 21:28
  • Dec 29 2016 21:28
  • Dec 29 2016 21:27
  • Dec 29 2016 21:27
  • Dec 29 2016 21:27
  • Dec 29 2016 21:27
  • Dec 29 2016 21:27
  • Dec 29 2016 21:27
  • Dec 29 2016 21:27
  • Dec 29 2016 21:27
  • Dec 29 2016 21:27
  • Dec 29 2016 21:27
  • Dec 29 2016 21:27
  • Dec 29 2016 21:27
  • Dec 29 2016 21:27
  • Dec 29 2016 21:27
  • Dec 29 2016 21:27
  • Dec 29 2016 21:27
Andrey
@Xambey

Hello, please tell me what can be done in my case? (Angular)

I have a model with a lot of elements and every time I call cloneDeep, the processing time of the model (almost doubles) is increased, although the model does not change significantly.

In this case, there is a page component that contains a list of tabs. In each tab, a complex component is generated. When I click on the tab, ngOnInit is called with cloneDeep for the model based on which the component is rendered

Lazy.gif
The model contains reactive properties.
julian-code
@julian-code
Hey guys. Is it possible to use intersectionBy with objects comparing two properties?
illuminist
@illuminist
@julian-code You can create iteratee that return a combinination of property, or use intersectionWith instead
julian-code
@julian-code
@illuminist yeah, i just tried that. However using _.isEqual is very costly.
      ctx.selectedPlayers.forEach((player) => {
        const comparableMatches = player.matches.map((match) => ({
          teamName: match.teamName,
          matchId: match.matchId,
          eloDiff: match.eloDiff,
          map: match.map,
          win: match.win,
          time: new Date(match.time),
        }));
        allMatches.push(comparableMatches);
      });
      return _.intersectionWith(...allMatches, _.isEqual);
illuminist
@illuminist
You should use your own comparator that compare between 2 properties
julian-code
@julian-code
what is send in after the ...allMatches?
As the second argument.
illuminist
@illuminist
That's the comparator
Its signature is (object1, object2) => boolean
julian-code
@julian-code
arhhh
I think I got it working now :D
illuminist
@illuminist
That's great
julian-code
@julian-code
 return _.intersectionWith(...allMatches,
        (match1, match2) => {
          if (match1.win === match2.win && match1.matchId === match2.matchId) {
            return true;
          }
          return false;
        });
Thanks for the help :)
illuminist
@illuminist
Glad too
julian-code
@julian-code
How do you find and set a value on a specific object in an array?
Or more like find a specific object and set a value on that object.
illuminist
@illuminist
Use findIndex to get index of object in an array then use that index to set object value
Alexander Sivashev
@shyr1punk
Hi. I'm interesting what community think about a this proposal: memoize: Warning: for memoized function with 2+ args use resolver lodash/lodash#4641 implemented here lodash/lodash#4702
If you like it, please send a reaction in issue or comment or suggest changes/help with implementation
julian-code
@julian-code
Hey guys. I need to loop through an array calculating the difference between current element and next element. Such as this in a for loop:
eloDiff: Number(x.elo) - Number(data[index + 1].elo),
Can you use some of lodashes functions to do the same?
julian-code
@julian-code
It should iterate over current and next.
SOULE Théo
@XxSven_gitlab
Hello, I have a little question about how lodash is delivered. The syntax is ;(function() {}.call(this)); yet on stackoverflow I can only found explanations for (function () {}).call(); the parenthesis is not at the same place
can someone please explain to me what is happening here as I am a beginner ?
illuminist
@illuminist
@XxSven_gitlab Those get evaluated to be the same, ultimately they become function () {}.call(this).
SOULE Théo
@XxSven_gitlab
@illuminist But when I write this in js fiddle I get syntax error if I don't surround it by parenthesis
illuminist
@illuminist
(function () {}) this one get boiled down into function object first before accessing .call, while (function () {}.call(this)) is an entire expression for function call
It isn't an usual syntax that you use in everyday job, but still good to know
SOULE Théo
@XxSven_gitlab
ok ty, it's weird ^^'
NursahKara
@NursahKara
hello, I am new in lodash so i don't know how to use with react native. I have a question. I have a project which is related to firebase. I want to see the information of which user logs in.With the map function, I can access all the data in the database but I only want to see the data of the logged-in user.should I use the find function to achieve this?Do you have a suggestion?
const mapStateToProps=state=>{
const currentUser=firebase.auth().currentUser;
const email=currentUser.email;
const profileInformationList=_.map(state.profileInformationList,(val,uid)=>{
return {...val,uid}
});
return {
profileInformationList
}
}
I want to use currentUser.email
illuminist
@illuminist
What is the shape of your state.profileInfomationList?
NursahKara
@NursahKara
it is an array
illuminist
@illuminist
What is the shape of object inside of the array?
NursahKara
@NursahKara
email name surname nick birthday
illuminist
@illuminist
So you want to find an object with email that match currentUser?
NursahKara
@NursahKara
yes
illuminist
@illuminist
Then it is better to use _.find to get one object from the array
NursahKara
@NursahKara
i think so too but i couldn't use it with react native
I can pull all the data with the map function, but it gets confused when I use the find function.
illuminist
@illuminist
It should not be difference from usual javascript regardless of what platform
NursahKara
@NursahKara
thanks your time @illuminist
WebAzOps
@WebAzOps
Selam kervan
thoo1
@thoo1
Does anyone know how _.isEqual treats date objects?
Does it compare using ===, or date1.getTime() === date2.getTime(), or some other way?
Reason I ask is because in my code, I am debugging, I am seeing that the two date objects I am comparing using _.isEqual is returning false even though the .getTime() for both dates are the same