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

how to sort an observable collection #6

Open
ahdinosaur opened this issue Feb 6, 2017 · 1 comment
Open

how to sort an observable collection #6

ahdinosaur opened this issue Feb 6, 2017 · 1 comment

Comments

@ahdinosaur
Copy link

hey @mmckegg @mixmix,

i noticed in the patchbay /network page, when migrating to use mutant observables we stopped using our peerListSort function. so when browsing the page, the peers i want to see (the ones i'm connected to) are randomly scattered about.

i attempted to write a function to sort a collection observable like so:

function sort (obsCollection, comparator) {
  const result = MutantArray()
  obsCollection(collection => {
    const sorted = collection.slice().sort(comparator)
    result.set(sorted)
  })
  return result
}

but the problem is that this "flattens" the collection of nested observables into a collection of values, which would lead to changes in our render functions with h.

any advice on how to do this properly? and should this be something included in mutant?

chur!

mmckegg added a commit to ssbc/patchbay that referenced this issue Feb 6, 2017
@mmckegg
Copy link
Owner

mmckegg commented Feb 6, 2017

Hey @ahdinosaur! Yes, I think you are right that it should be a mutant transform. I think it should work like map but instead of changing the output, changes the order.

Here's how i would implement sorting in patchbay (without a special mutant transform):

ssbc/patchbay@ef1aeb9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants