This project is read-only.

Linq Js Distinct Doesn't work


i'm developing an angularJs application, which has a history, the history get filled by user search, and then store in localStorage, the process is like this:
function queue(searchHistory) {
                var dataList = getData(); //from local storage

                //Add New Data

                //Remove Repeated Data
                var dataList = Enumerable.From(dataList)
                    .Distinct("$._sourceAirport._iataCode + '-' + $._destinationAirport._iataCode + $.startDate + '-' + $.endDate")

                //Decrease Queue Size To Its Max

                setData(dataList); //to local storage
what happen here, is the last item which come from function parameter won't confilict with repeated item inside the list.

you can see in watch that the first (new item) and last item (exists item) after running distinct are repeated...

file attachments


deadManN wrote Jan 12, 2016 at 9:44 AM

The Issue came from my side,
The first Object i generated by js and contains getter and setter, while the others doesn't have this, since i cant serialize it into the the string...

so this part, $.startDate + '-' + $.endDate" is defined for first, and "undefined" for other, make first item look different.

i had to trace the code deep into your codes, and i saw that which i didn't expect, i though i may failed becasue of encoding change after reading back from localStorage, not that one...

if there was a way to do something like this:


it was both traceable and understandable,... can you do that?