These are chat archives for ractivejs/ractive

10th
Apr 2018
Chris Reeves
@evs-chris
Apr 10 2018 07:24
@ceremcem that should still be working... perhaps resolveInstanceMembers is catching you too?
Cerem Cem ASLAN
@ceremcem
Apr 10 2018 08:54
console output says the function myHelper is not defined (is not a function)
Joseph
@fskreuz
Apr 10 2018 13:27
defaults should be the prototype though.
Check if a property in the chain is shadowing over it.
Chris Reeves
@evs-chris
Apr 10 2018 19:16
unless I'm misunderstanding, which is entirely possible, it appears to work
Cerem Cem ASLAN
@ceremcem
Apr 10 2018 20:48
I had dove into some kind of hardware design work, but since I occupy your attention, I think I should upgrade back to 0.10 in a few hours and see what was exactly wrong in my case
Joe Turner
@JoeTurner-IR
Apr 10 2018 21:08
can anyone think of a nice solution for swapping two columns in a ractively generated table?
pasting example code in a second
{{#each items: j}}
                <tr>
                    {{#each .cells}}
                        <td class="itemCell">
                            {{.value}}
                        </td>
                    {{/each}}
                </tr>
{{/each}}
simplified version
I guess I could just do it in a loop using a temporary variable
Joseph
@fskreuz
Apr 10 2018 21:11
Swap two columns entirely?
Joe Turner
@JoeTurner-IR
Apr 10 2018 21:11
so that I don't call .set() a load of times
but was hoping I could just do Ractive.splice(something really cool) :D
Joseph
@fskreuz
Apr 10 2018 21:12
What causes this swapping to happen?
Joe Turner
@JoeTurner-IR
Apr 10 2018 21:12
it would be like saying "move column 3 to position 6"
in a 1d array it's like this
myArray.splice(to, 0, myArray.splice(from, 1)[0]);
I guess I'll just do that in a loop
Joseph
@fskreuz
Apr 10 2018 21:14
Ok, let me collect my questions:
  • Are you swapping columns for multiple rows?
  • What determines position of the swap?
  • What causes the swap?
Because instinct tells me computed property that depends on the original data and some sort of array defining the order, and recreates the entire data according to that order.
Joe Turner
@JoeTurner-IR
Apr 10 2018 21:16
your instinct is correct
but I don't want to refire the computation of the whole table again
I think I have a solution, just gimmie a sec
Joseph
@fskreuz
Apr 10 2018 21:17
Aha! There's the constraint. So nope, no computed props for you. :D
Ractive does have ractive.splice https://ractive.js.org/api/#ractivesplice
Joe Turner
@JoeTurner-IR
Apr 10 2018 21:19
I think I'll do something like:
var items = this.get('items');
                var newItems = [];
                (items||[]).forEach(function(item) {
                    var cells = item.cells;
                    item.cells = cells.splice(to, 0, cells.splice(from, 1)[0]);
                    newItems.push(item);
                });
this.set('items', newItems);
I find myself doing a lot of this kind of stuff
so ractive.update() is only fired once
could look into getting a decent array manipulation library
Cerem Cem ASLAN
@ceremcem
Apr 10 2018 22:50
@evs-chris first feedback: overall application works with ractive@1.0.0-build-155 and broken by ractive@1.0.0-build-156.
Cerem Cem ASLAN
@ceremcem
Apr 10 2018 22:55
my use case is like this one
the same example is broken by 0.10
Paul Maly
@PaulMaly_twitter
Apr 10 2018 23:02
Do you set?: Ractive.defaults.resolveInstanceMembers = true;
Cerem Cem ASLAN
@ceremcem
Apr 10 2018 23:03
:+1:
I mistakenly tried to set resolveInstanceMembers to true by:
new Ractive({
    el: 'body', 
    template: `
        <bar /> 
    `,
    resolveInstanceMembers: true

})
Paul Maly
@PaulMaly_twitter
Apr 10 2018 23:05
:+1:
Cerem Cem ASLAN
@ceremcem
Apr 10 2018 23:05
setting Ractive.defaults.resolveInstanceMembers = true; perfectly solved the issue
Chris Reeves
@evs-chris
Apr 10 2018 23:17
yes, that's not an inherited setting, so sub components wouldn't pick it up from an instance
inherited from template owner, I should say
it definitely is inherited by extends
Cerem Cem ASLAN
@ceremcem
Apr 10 2018 23:20
...which means this also works