Hi Max,

Yes, the title of the section "Adding private or static variables" is
confusing, since it only shows variables that
are both static AND private.

https://www.polymer-project.org/docs/polymer/polymer.html#static

If you want to store state outside of the prototype, you can add properties
on this, as you would with any JavaScript object. A good time to do this is
in the created callback. This is discussed in the context of published
properties, here:

https://www.polymer-project.org/docs/polymer/polymer.html#default-property-values

This jsbin:

http://jsbin.com/fitahe/15/edit

Shows a private instance variable, exposed via a (published) getter and
setter.

Note that in this example, I'm binding to the published name, foo. If the
property wasn't published, I'd need to bind to the private name, foo_. I'm
not sure whether data binding is relevant to your use case -- I'm only
using it here to demonstrate that each instance has its own foo_ value.

Hope this helps,
Arthur


On Mon, Oct 6, 2014 at 9:38 AM, Max Waterman <[email protected]> wrote:

> (advised by Mr Dodson to post this question here rather than on G+)
>
> I see[0] how to make private static functions and properties - they're
> common to all instances of the element - but how to make private instance
> functions and properties so we can store state outside the prototype?
>
> Any ideas?
>
> Thanks,
>
> Max.
>
> [0] <https://www.polymer-project.org/docs/polymer/polymer.html#static>
>
> Follow Polymer on Google+: plus.google.com/107187849809354688692
> ---
> You received this message because you are subscribed to the Google Groups
> "Polymer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/polymer-dev/2a7b2405-436e-4798-9357-b7dd3dcf8bb3%40googlegroups.com
> <https://groups.google.com/d/msgid/polymer-dev/2a7b2405-436e-4798-9357-b7dd3dcf8bb3%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

Follow Polymer on Google+: plus.google.com/107187849809354688692
--- 
You received this message because you are subscribed to the Google Groups 
"Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/polymer-dev/CADSbU_y%2B9jExamruWno0JWaZv8mpLE-7vzYdXu3chL_C2u%2B0Kg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to