These are chat archives for ractivejs/ractive

4th
Nov 2018
kouts
@kouts
Nov 04 2018 19:31
been away for a while, thanks, so a plugin will not help if I want to mess with the template of an instance, AFAIK plugins don't have access to construct right?
Chris Reeves
@evs-chris
Nov 04 2018 21:29
they should as long as you don't pass them directly in instance.use() because the component is already constructed at that point
Cerem Cem ASLAN
@ceremcem
Nov 04 2018 21:34
@kouts you really seem to build something interesting :)
kouts
@kouts
Nov 04 2018 21:35
Naaahh, just refactoring!
:smiley:
Cerem Cem ASLAN
@ceremcem
Nov 04 2018 21:37
whole application will be interesting? :D
kouts
@kouts
Nov 04 2018 21:41
I'm not even remotely to the interesting part yet, I'm porting "old" code to new project with new standards so always a good time for cleanup.
For the upcoming months I'll be working on a UI for a Middleware system
kouts
@kouts
Nov 04 2018 21:51
A completely different question: I'm in a situation that I need a computed property inside a loop.
What I have done now is that I have setup a method (inside data) which takes the context as a parameter, performs the calculations and sets (ctx.set(...)) the appropriate variable.
This method is inside the loop in the template
it doesn't "print" anything, it just exists there in order to perform the caclulation
Is this ok?
Cerem Cem ASLAN
@ceremcem
Nov 04 2018 21:53
like x = [{a: 1, b: function(ctx)}, {a: 2, b: function(ctx)}, ...]?
kouts
@kouts
Nov 04 2018 21:56
No, it's not defined inside the loop data
something like
data: function(){
            return {
                calc_method: function(ctx, some_id){
                    ctx.set('somevar', calc_result_here);
                }
            }
so this calc_method is then referenced inside the template
Cerem Cem ASLAN
@ceremcem
Nov 04 2018 21:59
hm. I got it
kouts
@kouts
Nov 04 2018 21:59
Imagine that I want something like a computed property for each "line" of the loop
Cerem Cem ASLAN
@ceremcem
Nov 04 2018 22:00
I needed that before and I ended up with using a component, only for that reason
Chris Reeves
@evs-chris
Nov 04 2018 22:01
Youcan have computeds at wildcard keypaths, and they receive a context when they're called iirc
Cerem Cem ASLAN
@ceremcem
Nov 04 2018 22:01
like this. so your approach seems okay from the point of view of me
Chris Reeves
@evs-chris
Nov 04 2018 22:02
but if what you have works and is easier to reason about, it's perfectly valid
kouts
@kouts
Nov 04 2018 22:04
@evs-chris Is the "computeds at wildcard keypaths" feature documented?
seems to be what I need
Chris Reeves
@evs-chris
Nov 04 2018 22:04
Uhhhh, hold on 😁
Looks like I missed it in the actual docs, but it's covered in the original pr ractivejs/ractive#3141
mehdip
@mehdip
Nov 04 2018 22:10
hi
Chris Reeves
@evs-chris
Nov 04 2018 22:11
👋
kouts
@kouts
Nov 04 2018 22:11
thanks @evs-chris I'll take a look
Cerem Cem ASLAN
@ceremcem
Nov 04 2018 22:17
hey, welcome
kouts
@kouts
Nov 04 2018 22:18
welcome @mehdip