I have a class (LiveScript) that is instantiated once, but its render
method is called many times. Each object created in the render
method must have a unique key that stays the same across all invocations of render
:
class Test
->
console.log 'constructor, called only once'
render: ->
test = {key: 4124312}
test1 = {key: 234897}
test2 = {key: 87234}
This works, but instead of hardcoding the key I'd rather generate it. Using a random number will not work since that will generate a new key on each invocation of render
. Having some list of keys outside this class and popping items of them won't work either because the order of the created objects in render
could change. Any idea if and how I could generate the keys?