These are chat archives for ractivejs/ractive

9th
Apr 2018
kouts
@kouts
Apr 09 2018 08:42
Hi all, can someone give an example how resolveInstanceMembers now defaulting to false, might create problems in existing codebases?
BTW in docs it states that the default is true
Paul Maly
@PaulMaly_twitter
Apr 09 2018 09:03
I believe only if you use instance members directly:
<button on-click="set('foo', 'bar')">Set foo</button>
I usually does it, but Chris advise use an instance reference:
<button on-click="@.set('foo', 'bar')">Set foo</button>
<button on-click="@this.set('foo', 'bar')">Set foo</button>
kouts
@kouts
Apr 09 2018 09:27
Ahh I see, I always use them like @this.set(...
thanks @PaulMaly_twitter
Paul Maly
@PaulMaly_twitter
Apr 09 2018 09:29
So, if you don't need that, seems Ractive would be a little bit more performant if you'll use resolveInstanceMembers: false
kouts
@kouts
Apr 09 2018 09:34
yes and resolveInstanceMembers: false seems to be the default in 0.10.0
Joseph
@fskreuz
Apr 09 2018 12:52
If you use non-config properties as data, you won't be able to reference them without @this. For instance, this
// user resolves to init.user
const ResolveEnabled = Ractive.extend({
    template: `<div>Hello, {{ user }}. Good evening!</div>`,
    user: 'admin',
    resolveInstanceMembers: true
})

// user is undefined
const ResolveDisabled = Ractive.extend({
    template: `<div>Hello, {{ user }}. Good evening!</div>`,
    user: 'admin',
    resolveInstanceMembers: false
})

// user explicitly says it's init.user
const ResolveExplicit = Ractive.extend({
    template: `<div>Hello, {{ @this.user }}. Good evening!</div>`,
    user: 'admin',
    resolveInstanceMembers: false
})

ResolveEnabled({ target: document.body, append: true })
ResolveDisabled({ target: document.body, append: true })
ResolveExplicit({ target: document.body, append: true })
Paul Maly
@PaulMaly_twitter
Apr 09 2018 12:56
Yep, any instance method or property.
Cerem Cem ASLAN
@ceremcem
Apr 09 2018 15:19
What happened to Ractive.defaults.myHelper = function ...?
it's gone by 0.10?
kouts
@kouts
Apr 09 2018 16:24
@fskreuz does this also apply to methods?
Joseph
@fskreuz
Apr 09 2018 16:26
Yup. That's what @PaulMaly_twitter mentioned earlier.
kouts
@kouts
Apr 09 2018 16:28
I think I'm on the safe side, but I'll double check before upgrading, thanks.