-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support custom sort functions #26
Comments
A work around would be to add additional properties like |
@m-mujica when querying, is case also ignored? Should |
This works, does that solve it for you @m-mujica ? function StringIgnoreCaseSet(value){
this.value = value;
}
StringIgnoreCaseSet.prototype.valueOf = function(){
return this.value.toLowerCase();
};
canReflect.assignSymbols(StringIgnoreCaseSet.prototype,{
"can.serialize": function(){
return this.value;
}
});
var StringIgnoreCase = canReflect.assignSymbols({},{
"can.SetType": StringIgnoreCaseSet,
"can.new": function(value){
return value;
}
});
var queryLogic = new QueryLogic({
keys: {
name: StringIgnoreCase
},
identity: ["id"]
});
var filter = queryLogic.filterMembers(
{sort: "name"},
[{id: 1, name: "grab coffee"},
{id: 2, name: "finish these docs"},
{id: 3, name: "Learn CanJS"}]
);
QUnit.deepEqual([
{id: 2, name: "finish these docs"},
{id: 1, name: "grab coffee"},
{id: 3, name: "Learn CanJS"}
], filter); |
@justinbmeyer I haven't tried this out... About the querying, yes, the casing is totally ignored. I'lll let you know once I test your workaround. Thanks. |
Sometimes you have to use a custom sort function on Lists, being unable to use this function in can-query-logic means that unexpected insertion/removals will happen when using real-time.
When real-time tries to figure where a new (or existing) item should be placed on the lists it calls getIndex which will sometimes not match the position where the instance "should be placed" based on the
sortByName
comparator logic.Ideally we should be able to pass
sortByName
so can-query-logic can determine the position correctly.The text was updated successfully, but these errors were encountered: