These are chat archives for ractivejs/ractive

22nd
Dec 2017
shal1y
@shal1y
Dec 22 2017 00:24
Hey guys... I get this issue where in ractive 0.8.12/14 during init the system tries to set the computed properties (which are just getters) and sends out the error : Cannot set read-only computed value.... I can fix it by putting an empty setter, but wanted to see if anyone knew why is that caused.
Chris Reeves
@evs-chris
Dec 22 2017 01:36
There are a few things that can cause that, like using a computed in a form binding or setting up a mapping to a component where the component side is a computed.
shal1y
@shal1y
Dec 22 2017 07:05
@evs-chris well the above cases are not what I have... maybe I could make a codepen or fiddle so you could check it
Paul Maly
@PaulMaly_twitter
Dec 22 2017 08:18

@shal1y Are you setup computed property like this:

computed: {
     myprop: function() {}
}

or this:

computed: {
     myprop: {
          get: function() {}
     }
}
?
shal1y
@shal1y
Dec 22 2017 09:54

@PaulMaly_twitter I had it like

computed : {
    myProp : function() {}
}

but when I started getting the error above, I switched to

computed : {
    myProp : {
        get () {}
        set (value) {// this remains empty because I don't use it}
    }
}

The above setup kinda gets rid of the Cannot set read-only computed value... error

Paul Maly
@PaulMaly_twitter
Dec 22 2017 10:07
Hm, strange. Please provide an exàmple here: http://ractive.js.org/playground/
You can choose Ractive version in settings
Only warning in console
Joseph
@fskreuz
Dec 22 2017 14:17
The most common case is binding a read-only computed to an input. However, anything trying to set to a read-only computed can trigger this warning, like a manual ractive.set(). Assuming "init system" means the initialization lifecycle events (config, init, render, complete), try looking for calls to ractive.set(). Also, observers are run once during initialization (unless its init option is set to false). Might be a good place to look at as well. In any case, try adding a breakpoint on that warning and trace what's causing it. I bet you a virtual cookie there's a rogue ractive.set() somewhere. :grin:
This also might be a good "better docs/good first issue" issue. Feel free to write up an issue so we can track and fix. :+1:
shal1y
@shal1y
Dec 22 2017 18:18
@PaulMaly_twitter @fskreuz ... thanks for the insight guys! I was able to track the issue and find what was going on. I had the property described in one of the objects that I was extending from. I re-defined the prop as a computation where I was getting the error. Thanks a lot for the help :)
Paul Maly
@PaulMaly_twitter
Dec 22 2017 18:19
Nice! ))