Yomguithereal / baobab-react

React integration for Baobab.
MIT License
310 stars 38 forks source link

Filtering an array via cursor #129

Closed soulprovidr closed 6 years ago

soulprovidr commented 6 years ago

Hi, first of all, thanks a lot for your work on baobab.

I'm wondering if it would be possible to filter an array via a cursor like this:

export default branch({ filteredChats: [ 'chats', { active: true } ], }, ChatList);

Currently, the library returns the first item it encounters that matches the condition, but it would be cool to be able to filter the array based on the condition instead.

Thanks!

Zache commented 6 years ago

Why not use a monkey?

Den tis 13 mars 2018 18:38Shola Anozie notifications@github.com skrev:

Hi, first of all, thanks a lot for your work on baobab.

I'm wondering if it would be possible to filter an array via a cursor like this:

export default branch({ filteredChats: [ 'chats', { active: true } ], }, ChatList);

Currently, the library returns the first item it encounters that matches the condition, but it would be cool to be able to filter the array based on the condition instead.

Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Yomguithereal/baobab-react/issues/129, or mute the thread https://github.com/notifications/unsubscribe-auth/ADYLwBdIurvtysu2k4qBT7721oMAMOjpks5teAP-gaJpZM4SpJIH .

Yomguithereal commented 6 years ago

Hello @soulprovidr. @Zache is right. The right tool for the job is probably a monkey. The fact is a cursor cannot be ambiguous and point to several parts of the tree at once.

soulprovidr commented 6 years ago

Thanks a lot, I appreciate your input. I'll use a monkey for this. 👍