Skip to content
This repository has been archived by the owner on Jul 14, 2020. It is now read-only.

Helper for checking every member of a collection against a predicate #3

Closed
Robdel12 opened this issue Apr 15, 2018 · 1 comment
Closed
Labels
enhancement New feature or request

Comments

@Robdel12
Copy link
Contributor

Robdel12 commented Apr 15, 2018

It would be nice to have a way to check every member of a collection against a predicate that returns the results &&ed together.

Given a collection such:

  items = collection($selector, {
    isSelected: hasClass('selected', $child)
  });

The ability to add something like the following property would be boss:

  allItemsSelected = all(this.items(), item => item.isSelected);

(moved from thefrontside/bigtest#65)

@Robdel12 Robdel12 added the enhancement New feature or request label Apr 15, 2018
@wwilsman
Copy link
Contributor

wwilsman commented Jul 3, 2018

I don't think a helper for this is necessary, and it would get complicated in relation to this.

We could simply use a getter instead :)

items = collection($selector, {
   isSelected: hasClass('selected', $child)
});

get allItemsSelected() {
   return this.items().every(item => item.isSelected);
}

@wwilsman wwilsman closed this as completed Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants