javascript object pattern for a periodically updating object
<p>I want to periodically update a js object (after an initialization when the object is created), and was attempting the following:</p>

<pre><code>var data = {
    foo: -1,
    bar: -1,
    refresh: function() {
        this.foo = getFoo();
        this.bar = getBar();
    }()
}
</code></pre>

<p>This doesnt currently work at the moment, the <code>this</code> doesnt seem to refer to the data object. There are a few different permutations I could try here - but wondering if i am barking up the wrong tree here? What sort of pattern should I be using for an object that I need to periodically update (called externally).</p>
