InsertArrayItem for sets?

Can I have the source of the itemArrays for an object as sets? I need to have a collection that guarantees me that there are no duplicates within. I would think the only problem would be with AddArrayItem and RemoveArrayItem right? Can I create extensions to these methods to make them set-compatible?

JavaScript Arrays do not have an option to disallow duplicates, so you will need to implement this yourself by checking for a duplicate, according to your own notion of equality, before calling Model.addArrayItem.

There’s probably no reason to change the behavior of Model.removeArrayItem.

Yes, thats why I made a custom collection based on a map…

Model.addArrayItem just calls Model.insertArrayItem, and neither method is overridable.

Model.insertArrayItem always raises an Insert ChangedEvent because it does not check whether the insertion succeeded or not – it assumes that the call to push or splice will succeed. That means that a duplicate insertion would raise a ChangedEvent that would be undone upon an undo, which is not the behavior that you want.

Can I raise the change event myself? If so, how would I go about that? I see that I could go with Node.raiseDataChanged, but what would be the params here?

data -> the nodeData containing the array
propertyName -> the array itself?
oldVal -> Set b4 change?
newVal -> Set after change?
oldparam -> ???
newparam -> ???

You cannot override the method, so I think your question is moot.

Just don’t call Model.addArrayItem or Model.insertArrayItem if it’s already a member of the Array.