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

No sort() method? #81

Closed
unclecheese opened this issue May 1, 2015 · 5 comments
Closed

No sort() method? #81

unclecheese opened this issue May 1, 2015 · 5 comments

Comments

@unclecheese
Copy link

Is there a reason why sort() was left out of the ArrayWrapper? If so, how do you recommend dealing with sort?

@mquan
Copy link
Owner

mquan commented May 8, 2015

Interesting, this never crosses my mind. An issue I can foresee is you'd expect the result of the sort has to be a new cortex object. Currently, If you want to sort and mutate the array then you can sort the array value first and then set it to the sorted version. I could be wrong but I don't see a use case where you need a sorted cortex wrapper but not mutate the original array wrapper

@unclecheese
Copy link
Author

That's what I thought, too -- just set the property to a new array. That wasn't working for me, though. I think it's because my array is nested. Can you confirm that this:

myCortexObject.someObject.someArray.set(newArray)

Will not fire an update event? I just want to make sure I'm not crazy. It sounds like Cortex prefers that everything is at the root level.

@mquan
Copy link
Owner

mquan commented May 8, 2015

You change the content of the cortex object so of course it will fire an update event. Because otherwise how would component update when your data changed? If you don't want to fire an update then may be it shouldn't be part of your cortex object. The whole point of cortex is to allow you to pass nested data to nested children as props and be able to trigger update from any child component

@unclecheese
Copy link
Author

OK, yeah, I actually do want it to fire an update event. The documentation is kind of ambiguous, though. You show an example for the set() method against an end point, e.g. data.items[0].title.set('foo'), and also from the root object, e.c. data.set({items: [...]}), but not that you can run set() at any intermediate point, like data.items.set(newArray).

Can you just confirm that all three of those set() methods should work the same way? I have a feeling it's my implementation, but I just want to be sure it's not some idiosyncrasy that I missed.

@mquan
Copy link
Owner

mquan commented May 10, 2015

anywhere you call set() which causes a real change update event will be triggered

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