-
Notifications
You must be signed in to change notification settings - Fork 397
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
Add support for auto shuffling at the iterative block level #3221
Conversation
Hi Chris, as a comment, I'd like to point out the syntax is somewhat misleading. First, |
The same thoughts. I think we need to have some real example of this feature. |
I'll agree that the syntax is not the best possible way to communicate this, but it's the best compromise I could come up with that fits the rest of what's available in ractive. The The shuffle part is also very closely related to (well, overlapping with) the second part of this pr, which is mapped iteration contexts, wherein you can instruct an each block to use a list element's source model for the iteration context rather than a computed child context. The easiest way to explain that is All that said, these are experimental features that I wanted to get a bit of exposure for for feedback, and they don't affect anything if not specifically invoked, making them safe to include in a stable build. |
hmmm, just to have another example. This:
Would work as Svelte's keyed each blocks?
|
It does indeed. |
Thank you Chris! This is an awesome feature! 😊 |
Thanks, I, at last, have understood a purpose. Excellent work, @evs-chris ! |
Description:
This adds experimental support for automatic shuffling at the iterative block level, which means that you can tell an
{{#each}}
block that (or how) to shuffle and it will do so even on regular set updates. This opens up the ability to have shuffling in an iterative section that is dealing with a computed value.The alias syntax is used for consistency and parse-abilty, even though it's not necessarily the most ideal way to convey this particular directive. I'm also planning to add the ability to set the iteration context based on a lookup in a source array via
That will allow, among other things, filtering lists with bindings without having to do the whole
syncComputedChildren
thing.Regarding the keypath version of the shuffle setting, I chose to use a string rather than a reference to allow future shuffling based on a function.
If I feel particularly frisky, I may also try to get a shuffle transition in here too, but I may punt on that for now, as this is the last set of things that I want to get in before I cut 0.10.
Fixes the following issues:
#3097 #2947
Is breaking:
Nope