<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[setState, @nosync, and other properties]]></title><description><![CDATA[<p>I understand that I'm supposed to call setState to initialize my state and that state gets synced. I understand that I should call @nosync for properties <em>inside</em> my state that I do not want synced.</p>
<p>What happens if I have properties in my room outside the state without @nosync? For example, if I do something like the following, will the <code>secrets</code> property get synced?</p>
<pre><code>export class BattleRoom extends Room {

  onInit (options: any) {
    this.setState({
      players: {}
    });
    this.secrets = {x: 1, y:2}
  }
  // other code omitted
}
</code></pre>
]]></description><link>http://discuss.colyseus.io/topic/224/setstate-nosync-and-other-properties</link><generator>RSS for Node</generator><lastBuildDate>Sat, 14 Mar 2026 13:29:36 GMT</lastBuildDate><atom:link href="http://discuss.colyseus.io/topic/224.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 17 Mar 2019 03:01:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to setState, @nosync, and other properties on Invalid Date]]></title><description><![CDATA[<p>I understand that I'm supposed to call setState to initialize my state and that state gets synced. I understand that I should call @nosync for properties <em>inside</em> my state that I do not want synced.</p>
<p>What happens if I have properties in my room outside the state without @nosync? For example, if I do something like the following, will the <code>secrets</code> property get synced?</p>
<pre><code>export class BattleRoom extends Room {

  onInit (options: any) {
    this.setState({
      players: {}
    });
    this.secrets = {x: 1, y:2}
  }
  // other code omitted
}
</code></pre>
]]></description><link>http://discuss.colyseus.io/post/748</link><guid isPermaLink="true">http://discuss.colyseus.io/post/748</guid><dc:creator><![CDATA[cmdt.ed]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to setState, @nosync, and other properties on Invalid Date]]></title><description><![CDATA[<p>It won't, only the <code>state</code> is synced automatically.</p>
]]></description><link>http://discuss.colyseus.io/post/750</link><guid isPermaLink="true">http://discuss.colyseus.io/post/750</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to setState, @nosync, and other properties on Invalid Date]]></title><description><![CDATA[<p>Excellent! Thanks for the quick response.</p>
<p>I was confused on this so I'll summarize in case others come to this post in the future.</p>
<p>The @nosync decorator is needed because you might create an object foo that will be inside the state object and foo has properties bar and baz with bar being visible and baz being private. You would then use @nosync on baz since it is something inside the state that you want private. But for just other properties of the room but outside the state, those will not be synced.</p>
]]></description><link>http://discuss.colyseus.io/post/752</link><guid isPermaLink="true">http://discuss.colyseus.io/post/752</guid><dc:creator><![CDATA[cmdt.ed]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>