Skip to content
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

hd.list proxy functions #36

Closed
philipvr opened this issue Jun 26, 2012 · 3 comments
Closed

hd.list proxy functions #36

philipvr opened this issue Jun 26, 2012 · 3 comments

Comments

@philipvr
Copy link
Contributor

Knockout has implemented the standard array functions for their ko.observableArray such as push, pop, unshift, shift, reverse, sort, etc. (see ko documentation).

Hotdrink only has push, pop, remove for hd.list. I have already implemented removeAll and sort. Should I continue to implement these functions so that Hotdrink is on par with Knockout in this area?

@thejohnfreeman
Copy link
Member

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.

@philipvr
Copy link
Contributor Author

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, or undefined 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.

@thejohnfreeman
Copy link
Member

That functionality should be folded into remove. Just have it iterate over all arguments instead of taking a single argument.

thejohnfreeman added a commit to thejohnfreeman/hotdrink that referenced this issue Jul 10, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants