Closed philipvr closed 12 years ago
Yes, all reasonable methods will need to be implemented eventually, but Knockout is not our guide here. Consult MDN for standard array methods[^1] and provide the same interface.
We want to provide some simple helpers beyond the standard interface. I implemented remove
already. Instead of removeAll
, our method should be called clear
. Perhaps add an isEmpty
. Consult the other helpers I added to Array
for more ideas: has
, setUnion
, setIntersect
, setInsert
, etc.
[^1] Note that toSource
is non-standard.
I implemented the removeAll
function that takes an array and removes the items contained in the array:
myObservableArray.removeAll(['Chad', 132, undefined])
removes all values that equal'Chad'
,123
, orundefined
and returns them as an array
My removeAll
function does not remove all elements from the array when no argument is passed (I didn't implement this yet). I agree that removeAll
is not the best name for this function.
That functionality should be folded into remove
. Just have it iterate over all arguments
instead of taking a single argument.
Knockout has implemented the standard array functions for their
ko.observableArray
such aspush
,pop
,unshift
,shift
,reverse
,sort
, etc. (see ko documentation).Hotdrink only has
push
,pop
,remove
forhd.list
. I have already implementedremoveAll
andsort
. Should I continue to implement these functions so that Hotdrink is on par with Knockout in this area?